发送图片消息。

        :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source
        :param media_id: 图片的媒体ID。 可以通过 :func:`upload_media` 上传。
        :param kf_account: 发送消息的客服账户，默认值为 None，None 为不指定
        :return: 返回的 JSON 数据包
14278
def send_image_message(self, user_id, media_id, kf_account=None):
        
        data = {
            "touser": user_id,
            "msgtype": "image",
            "image": {
                "media_id": media_id
            }
        }
        if kf_account is not None:
            data['customservice'] = {'kf_account': kf_account}
        return self.post(
            url="https://api.weixin.qq.com/cgi-bin/message/custom/send",
            data=data
        )
664210
public function previewMpnews($media_id = '', $userid = '', $type = 'openid')
    {
        $queryStr = [];

        if ($type == 'towxname') {
            $queryStr['towxname'] = $userid;
        } else {
            $queryStr['touser'] = $userid;
        }

        $queryStr['mpnews']['media_id'] = $media_id;
        $queryStr['msgtype']            = 'mpnews';

        $this->module = 'message';

        $res = $this->_post('mass/preview', $queryStr);

        return $res;
    }
117707
public function getForeverMedia($media_id, $is_video = false)
    {
        if (!$this->access_token && !$this->getAccessToken()) {
            return false;
        }
        $data = array('media_id' => $media_id);
        $result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_GET_URL . "access_token={$this->access_token}", Tools::json_encode($data));
        if ($result) {
            if (is_string($result) && ($json = json_decode($result, true))) {
                if (isset($json['errcode'])) {
                    $this->errCode = $json['errcode'];
                    $this->errMsg = $json['errmsg'];
                    return $this->checkRetry(__FUNCTION__, func_get_args());
                }
                return $json;
            }
            return $result;
        }
        return false;
    }
327162
def download_permanent_media(self, media_id):
        
        return requests.post(
            url="https://api.weixin.qq.com/cgi-bin/material/get_material",
            params={"access_token": self.token},
            data=_json.dumps({
                "media_id": media_id
            }, ensure_ascii=False).encode("utf-8")
        )
126575
def find_video_detail_by_id(self, video_id, ext=None):
        
        url = 'https://api.youku.com/videos/show.json'
        params = {
            'client_id': self.client_id,
            'video_id': video_id
        }
        if ext:
            params['ext'] = ext
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
194402
def find_next_video_in_playlist(self, playlist_id, cur_video_id):
        
        url = 'https://openapi.youku.com/v2/playlists/video/next.json'
        params = {
            'client_id': self.client_id,
            'playlist_id': playlist_id,
            'video_id': cur_video_id
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
449667
public static function generateAvatarMarkup($user_id)
    {
        $filetypes = ['jpg', 'gif', 'png'];
        $avatar_markup = '';

        foreach ($filetypes as $cur_type) {
            $path = ForumSettings::get('o_avatars_dir') . '/' . $user_id . '.' . $cur_type;

            if (file_exists(ForumEnv::get('WEB_ROOT') . $path) &&
                $img_size = getimagesize(ForumEnv::get('WEB_ROOT') . $path)
            ) {
                $avatar_markup = '<img class="avatar" src="' .
                    \RunBB\Core\Utils::escape(Container::get('url')->base() . $path . '?m=' .
                        filemtime(ForumEnv::get('WEB_ROOT') . $path)) . '" ' . $img_size[3] . ' alt="" />';
                break;
            }
        }

        return $avatar_markup;
    }
1142836
public function openidImage($media_id = '', $openids = [])
    {
        $queryStr                      = [];
        $queryStr['touser']            = $openids;
        $queryStr['image']['media_id'] = $media_id;
        $queryStr['msgtype']           = 'image';

        $this->module = 'message';

        $res = $this->_post('mass/send', $queryStr);

        return $res;
    }
182545
public function get($media_id)
    {
        if (!is_string($media_id)) {
            $this->setError('参数错误,媒体ID参数错误');

            return false;
        }

        $queryStr = [
            'media_id' => $media_id,
        ];

        $res = $this->_post('get_material', $queryStr);

        return $res;
    }
562728
def media_upload(self, filename, *args, **kwargs):
        
        f = kwargs.pop('file', None)
        headers, post_data = API._pack_image(filename, 4883, form_field='media', f=f)
        kwargs.update({'headers': headers, 'post_data': post_data})

        return bind_api(
            api=self,
            path='/media/upload.json',
            method='POST',
            payload_type='media',
            allowed_param=[],
            require_auth=True,
            upload_api=True
        )(*args, **kwargs)
446437
public function getMedia($media_id, $is_video = false)
    {
        if (!$this->access_token && !$this->getAccessToken()) {
            return false;
        }
        $result = Tools::httpGet(self::API_URL_PREFIX . self::MEDIA_GET_URL . "access_token={$this->access_token}" . '&media_id=' . $media_id);
        if ($result) {
            if (is_string($result)) {
                $json = json_decode($result, true);
                if (isset($json['errcode'])) {
                    $this->errCode = $json['errcode'];
                    $this->errMsg = $json['errmsg'];
                    return $this->checkRetry(__FUNCTION__, func_get_args());
                }
            }
            return $result;
        }
        return false;
    }
1227535
def user_playlists(self, user_id, page=1, limit=30):
        
        action = 'mtop.alimusic.music.list.collectservice.getcollectbyuser'
        payload = {
            'userId': user_id,
            'pagingVO': {
                'page': page,
                'pageSize': limit
            }
        }
        code, msg, rv = self.request(action, payload)
        # TODO: 支持获取更多
        return rv['data']['data']['collects']
678224
def user(self, name):
        
        anime_data = requests.get(self.apiusers, params={'u': name, 'status': 'all', 'type': 'anime'},
                                  headers=self.header)

        if anime_data.status_code != 200:
            raise ConnectionError(
                "Anime Data Request failed. Please Open a bug on https://github.com/ccubed/Pymoe and include the following data.\nStatus Code: {}\n\nText:{}".format(
                    anime_data.status_code, anime_data.text))

        manga_data = requests.get(self.apiusers, params={'u': name, 'status': 'all', 'type': 'manga'},
                                  headers=self.header)

        if manga_data.status_code != 200:
            raise ConnectionError(
                "Manga Data Request failed. Please Open a bug on https://github.com/ccubed/Pymoe and include the following data.\nStatus Code: {}\n\nText:{}".format(
                    manga_data.status_code, manga_data.text))

        root = ET.fromstring(anime_data.text)
        uid = root.find('myinfo').find('user_id').text
        uname = root.find('myinfo').find('user_name').text
        anime_object_list = self.parse_anime_data(anime_data.text)
        manga_object_list = self.parse_manga_data(manga_data.text)
        return User(uid=uid,
                    name=uname,
                    anime_list=NT_USER_ANIME(
                        watching=[x for x in anime_object_list['data'] if x.status.user == "Currently Watching"],
                        completed=[x for x in anime_object_list['data'] if x.status.user == "Completed"],
                        held=[x for x in anime_object_list['data'] if x.status.user == "On Hold"],
                        dropped=[x for x in anime_object_list['data'] if x.status.user == "Dropped"],
                        planned=[x for x in anime_object_list['data'] if x.status.user == "Plan to Watch"]
                    ),
                    anime_days=anime_object_list['days'],
                    manga_list=NT_USER_MANGA(
                        reading=[x for x in manga_object_list['data'] if x.status.user == "Currently Reading"],
                        completed=[x for x in manga_object_list['data'] if x.status.user == "Completed"],
                        held=[x for x in manga_object_list['data'] if x.status.user == "On Hold"],
                        dropped=[x for x in manga_object_list['data'] if x.status.user == "Dropped"],
                        planned=[x for x in manga_object_list['data'] if x.status.user == "Plan to Read"]
                    ),
                    manga_days=manga_object_list['days'])
606687
def media_update(self, id, description=None, focus=None):
        
        id = self.__unpack_id(id)

        if focus != None:
            focus = str(focus[0]) + "," + str(focus[1])
            
        params = self.__generate_params(locals(), ['id'])  
        return self.__api_request('PUT', '/api/v1/media/{0}'.format(str(id)), params)
975213
def new_media_object(blog_id, username, password, media):
    
    authenticate(username, password)
    path = default_storage.save(Entry().image_upload_to(media['name']),
                                ContentFile(media['bits'].data))
    return {'url': default_storage.url(path)}
1224040
function (media_id, copy_options, cb) {

            if (copy_options) {
                copy_options._method = 'POST';
            }

            _util.buildQuery('medias/' + media_id + '/copy', copy_options, function (error, data) {

                return cb(error, data);

            });

        }
1042479
def info(self, media_id):
        
        dr = self.__app.native_api_call('media', 'i/' + media_id, {}, self.__options, False, None, False, http_path="/api/meta/v1/", http_method='GET')
        return json.loads(dr.text)