INSTRUCTION
stringlengths
1
46.3k
RESPONSE
stringlengths
75
80.2k
Fetch access token
def fetch_access_token(self): """ Fetch access token""" return self._fetch_access_token( url='https://qyapi.weixin.qq.com/cgi-bin/gettoken', params={ 'corpid': self.corp_id, 'corpsecret': self.secret } )
解析微信服务器推送的 XML 消息 :param xml: XML 消息 :return: 解析成功返回对应的消息或事件,否则返回 ``UnknownMessage``
def parse_message(xml): """ 解析微信服务器推送的 XML 消息 :param xml: XML 消息 :return: 解析成功返回对应的消息或事件,否则返回 ``UnknownMessage`` """ if not xml: return message = xmltodict.parse(to_text(xml))['xml'] message_type = message['MsgType'].lower() event_type = None if message_type == 'event' o...
发送文本消息 详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param content: 消息正文 :param account: 可选,客服账号 :return: 返回的 JSON 数据包 使用示例:: from wechatpy import WeChatClient ...
def send_text(self, user_id, content, account=None): """ 发送文本消息 详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param content: 消息正文 :param account: 可选,客服账号 :return: 返回的 JSON 数据...
发送图片消息 详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param media_id: 图片的媒体ID。 可以通过 :func:`upload_media` 上传。 :param account: 可选,客服账号 :return: 返回的 JSON 数据包 使用示例:: from we...
def send_image(self, user_id, media_id, account=None): """ 发送图片消息 详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param media_id: 图片的媒体ID。 可以通过 :func:`upload_media` 上传。 :param account:...
发送语音消息 详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param media_id: 发送的语音的媒体ID。 可以通过 :func:`upload_media` 上传。 :param account: 可选,客服账号 :return: 返回的 JSON 数据包 使用示例:: from...
def send_voice(self, user_id, media_id, account=None): """ 发送语音消息 详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param media_id: 发送的语音的媒体ID。 可以通过 :func:`upload_media` 上传。 :param accou...
发送视频消息 详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param media_id: 发送的视频的媒体ID。 可以通过 :func:`upload_media` 上传。 :param title: 视频消息的标题 :param description: 视频消息的描述 :param account: 可选,客服...
def send_video(self, user_id, media_id, title=None, description=None, account=None): """ 发送视频消息 详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param media_id: 发送的视频的媒体ID。 可...
发送音乐消息 详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param url: 音乐链接 :param hq_url: 高品质音乐链接,wifi环境优先使用该链接播放音乐 :param thumb_media_id: 缩略图的媒体ID。 可以通过 :func:`upload_media` 上传。 :param ti...
def send_music(self, user_id, url, hq_url, thumb_media_id, title=None, description=None, account=None): """ 发送音乐消息 详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param url:...
发送图文消息 详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param articles: 一个包含至多10个图文的数组, 或者微信图文消息素材 media_id :param account: 可选,客服账号 :return: 返回的 JSON 数据包
def send_articles(self, user_id, articles, account=None): """ 发送图文消息 详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param articles: 一个包含至多10个图文的数组, 或者微信图文消息素材 media_id :param account:...
发送卡券消息 详情请参参考 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140547 :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param card_id: 卡券 ID :param card_ext: 可选,卡券扩展信息 :param account: 可选,客服账号 :return: 返回的 JSON 数据包
def send_card(self, user_id, card_id, card_ext=None, account=None): """ 发送卡券消息 详情请参参考 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140547 :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param card_id: 卡券 ID :param card_ext: 可选,卡券扩展信息 :pa...
发送小程序卡片(要求小程序与公众号已关联) 详情请参参考 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140547 :param user_id: 用户 ID openid :param miniprogrampage: 小程序卡片信息 :param account: 可选,客服账号 :return: 返回的 JSON 数据包
def send_mini_program_page(self, user_id, miniprogrampage, account=None): """发送小程序卡片(要求小程序与公众号已关联) 详情请参参考 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140547 :param user_id: 用户 ID openid :param miniprogrampage: 小程序卡片信息 :param account: 可选,客服账号 :retu...
群发文本消息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1481187827_i0l21 :param group_or_users: 值为整型数字时为按分组群发,值为列表/元组时为按 OpenID 列表群发 当 is_to_all 为 True 时,传入 None 即对所有用户发送。 :param content: 消息正文 :param is_to_all: 用于设定是否向全部用户发送,值为true或false,选择true该消息群发给所有用户 ...
def send_mass_text(self, group_or_users, content, is_to_all=False, preview=False, send_ignore_reprint=0, client_msg_id=None): """ 群发文本消息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1481187827_i0l21 :param group_or_users: 值为整型数字时为按分组群发,...
群发视频消息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1481187827_i0l21 :param group_or_users: 值为整型数字时为按分组群发,值为列表/元组时为按 OpenID 列表群发 当 is_to_all 为 True 时,传入 None 即对所有用户发送。 :param media_id: 视频的媒体 ID。可以通过 :func:`upload_video` 上传。 :param title: 视频标题 ...
def send_mass_video(self, group_or_users, media_id, title=None, description=None, is_to_all=False, preview=False, send_ignore_reprint=0, client_msg_id=None): """ 群发视频消息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1481187827_i0l21 :pa...
群发图文消息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1481187827_i0l21 :param group_or_users: 值为整型数字时为按分组群发,值为列表/元组时为按 OpenID 列表群发 当 is_to_all 为 True 时,传入 None 即对所有用户发送。 :param media_id: 图文的媒体 ID。可以通过 :func:`upload_articles` 上传。 :param is_to_all: 用于设定是否...
def send_mass_article(self, group_or_users, media_id, is_to_all=False, preview=False, send_ignore_reprint=0, client_msg_id=None): """ 群发图文消息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1481187827_i0l21 :param group_or_users: 值为整型...
发送模板消息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1445241432&lang=zh_CN :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param template_id: 模板 ID。在公众平台线上模板库中选用模板获得 :param url: 链接地址 :param data: 模板消息数据 :param mini_program: 跳小程序所需数据, 如:`{'appid': 'appid', 'pagepat...
def send_template(self, user_id, template_id, data, url=None, mini_program=None): """ 发送模板消息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1445241432&lang=zh_CN :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param template_id: 模板 ID。在公众平台线上模板库中选用模板获得 :param url: ...
群发卡券消息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1481187827_i0l21 :param group_or_users: 值为整型数字时为按分组群发,值为列表/元组时为按 OpenID 列表群发 当 is_to_all 为 True 时,传入 None 即对所有用户发送。 :param card_id: 卡券 ID :param is_to_all: 用于设定是否向全部用户发送,值为true或false,选择true该消息群发给所有用户...
def send_mass_card(self, group_or_users, card_id, is_to_all=False, preview=False, send_ignore_reprint=0, client_msg_id=None): """ 群发卡券消息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1481187827_i0l21 :param group_or_users: 值为整型数字时为按分组群发,...
构造请求用户授权的url 详情请参阅: https://mp.weixin.qq.com/wiki?id=mp1500374289_66bvB :param scene: 订阅场景值,开发者可以填0-10000的整形值,用来标识订阅场景值 :type scene: int :param template_id: 订阅消息模板ID,登录公众平台后台,在接口权限列表处可查看订阅模板ID :param redirect_url: 授权后重定向的回调地址 :param reserved: 用于保持请求和回调的状态,授权请后原样带...
def get_subscribe_authorize_url(self, scene, template_id, redirect_url, reserved=None): """ 构造请求用户授权的url 详情请参阅: https://mp.weixin.qq.com/wiki?id=mp1500374289_66bvB :param scene: 订阅场景值,开发者可以填0-10000的整形值,用来标识订阅场景值 :type scene: int :param template_id: 订阅消息模板ID,登录公众平...
一次性订阅消息,通过API推送订阅模板消息给到授权微信用户。 详情请参阅: https://mp.weixin.qq.com/wiki?id=mp1500374289_66bvB :param openid: 填接收消息的用户openid :param template_id: 订阅消息模板ID :param scene: 订阅场景值,开发者可以填0-10000的整形值,用来标识订阅场景值 :type scene: int :param title: 消息标题,15字以内 :param data: 消息正...
def send_subscribe_template(self, openid, template_id, scene, title, data, url=None): """ 一次性订阅消息,通过API推送订阅模板消息给到授权微信用户。 详情请参阅: https://mp.weixin.qq.com/wiki?id=mp1500374289_66bvB :param openid: 填接收消息的用户openid :param template_id: 订阅消息模板ID :param scene: 订阅场景值,开发者可...
添加客服账号 详情请参考 http://mp.weixin.qq.com/wiki/1/70a29afed17f56d537c833f89be979c9.html :param account: 完整客服账号,格式为:账号前缀@公众号微信号 :param nickname: 客服昵称,最长6个汉字或12个英文字符 :param password: 客服账号登录密码 :return: 返回的 JSON 数据包
def add_account(self, account, nickname, password): """ 添加客服账号 详情请参考 http://mp.weixin.qq.com/wiki/1/70a29afed17f56d537c833f89be979c9.html :param account: 完整客服账号,格式为:账号前缀@公众号微信号 :param nickname: 客服昵称,最长6个汉字或12个英文字符 :param password: 客服账号登录密码 :return: 返回的 JS...
删除客服账号 详情请参考 http://mp.weixin.qq.com/wiki/1/70a29afed17f56d537c833f89be979c9.html :param account: 完整客服账号,格式为:账号前缀@公众号微信号 :return: 返回的 JSON 数据包
def delete_account(self, account): """ 删除客服账号 详情请参考 http://mp.weixin.qq.com/wiki/1/70a29afed17f56d537c833f89be979c9.html :param account: 完整客服账号,格式为:账号前缀@公众号微信号 :return: 返回的 JSON 数据包 """ params_data = [ 'access_token={0}'.format(quote(self.acce...
上传客服账号头像 详情请参考 http://mp.weixin.qq.com/wiki/1/70a29afed17f56d537c833f89be979c9.html :param account: 完整客服账号 :param media_file: 要上传的头像文件,一个 File-Object :return: 返回的 JSON 数据包
def upload_headimg(self, account, media_file): """ 上传客服账号头像 详情请参考 http://mp.weixin.qq.com/wiki/1/70a29afed17f56d537c833f89be979c9.html :param account: 完整客服账号 :param media_file: 要上传的头像文件,一个 File-Object :return: 返回的 JSON 数据包 """ return self._post( ...
多客服创建会话 详情请参考 http://mp.weixin.qq.com/wiki/2/6c20f3e323bdf5986cfcb33cbd3b829a.html :param openid: 客户 openid :param account: 完整客服账号 :param text: 附加信息,可选 :return: 返回的 JSON 数据包
def create_session(self, openid, account, text=None): """ 多客服创建会话 详情请参考 http://mp.weixin.qq.com/wiki/2/6c20f3e323bdf5986cfcb33cbd3b829a.html :param openid: 客户 openid :param account: 完整客服账号 :param text: 附加信息,可选 :return: 返回的 JSON 数据包 """ dat...
获取客服聊天记录 :param start_time: 查询开始时间,UNIX 时间戳 :param end_time: 查询结束时间,UNIX 时间戳,每次查询不能跨日查询 :param msgid: 消息id顺序从小到大,从1开始 :param number: 每次获取条数,最多10000条 :return: 返回的 JSON 数据包
def get_records(self, start_time, end_time, msgid=1, number=10000): """ 获取客服聊天记录 :param start_time: 查询开始时间,UNIX 时间戳 :param end_time: 查询结束时间,UNIX 时间戳,每次查询不能跨日查询 :param msgid: 消息id顺序从小到大,从1开始 :param number: 每次获取条数,最多10000条 :return: 返回的 JSON 数据包...
获取客服的会话列表 详情请参考 http://mp.weixin.qq.com/wiki/2/6c20f3e323bdf5986cfcb33cbd3b829a.html :param account: 完整客服账号 :return: 客服的会话列表
def get_session_list(self, account): """ 获取客服的会话列表 详情请参考 http://mp.weixin.qq.com/wiki/2/6c20f3e323bdf5986cfcb33cbd3b829a.html :param account: 完整客服账号 :return: 客服的会话列表 """ res = self._get( 'https://api.weixin.qq.com/customservice/kfsession/getse...
Create a reply quickly
def create_reply(reply, message=None, render=False): """ Create a reply quickly """ r = None if not reply: r = EmptyReply() elif isinstance(reply, BaseReply): r = reply if message: r.source = message.target r.target = message.source elif isinst...
反序列化被动回复 :param xml: 待反序列化的xml :param update_time: 是否用当前时间替换xml中的时间 :raises ValueError: 不能辨识的reply xml :rtype: wechatpy.replies.BaseReply
def deserialize_reply(xml, update_time=False): """ 反序列化被动回复 :param xml: 待反序列化的xml :param update_time: 是否用当前时间替换xml中的时间 :raises ValueError: 不能辨识的reply xml :rtype: wechatpy.replies.BaseReply """ if not xml: return EmptyReply() try: reply_dict = xmltodict.parse(xml)["xm...
Render reply from Python object to XML string
def render(self): """Render reply from Python object to XML string""" tpl = '<xml>\n{data}\n</xml>' nodes = [] msg_type = '<MsgType><![CDATA[{msg_type}]]></MsgType>'.format( msg_type=self.type ) nodes.append(msg_type) for name, field in self._fields.it...
获取 component_access_token 详情请参考 https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list\ &t=resource/res_list&verify=1&id=open1419318587&token=&lang=zh_CN :return: 返回的 JSON 数据包
def fetch_access_token(self): """ 获取 component_access_token 详情请参考 https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list\ &t=resource/res_list&verify=1&id=open1419318587&token=&lang=zh_CN :return: 返回的 JSON 数据包 """ url = '{0}{1}'.format( self....
The real fetch access token
def _fetch_access_token(self, url, data): """ The real fetch access token """ logger.info('Fetching component access token') res = self._http.post( url=url, data=data ) try: res.raise_for_status() except requests.RequestException as req...
快速获取pre auth url,可以直接微信中发送该链接,直接授权
def get_pre_auth_url_m(self, redirect_uri): """ 快速获取pre auth url,可以直接微信中发送该链接,直接授权 """ url = "https://mp.weixin.qq.com/safe/bindcomponent?action=bindcomponent&auth_type=3&no_scan=1&" redirect_uri = quote(redirect_uri, safe='') return "{0}component_appid={1}&pre_auth_code=...
使用授权码换取公众号的授权信息,同时储存token信息 :params authorization_code: 授权code,会在授权成功时返回给第三方平台,详见第三方平台授权流程说明
def query_auth(self, authorization_code): """ 使用授权码换取公众号的授权信息,同时储存token信息 :params authorization_code: 授权code,会在授权成功时返回给第三方平台,详见第三方平台授权流程说明 """ result = self._query_auth(authorization_code) assert result is not None \ and 'authorization_info' in result \ ...
获取(刷新)授权公众号的令牌 :params authorizer_appid: 授权方appid :params authorizer_refresh_token: 授权方的刷新令牌
def refresh_authorizer_token( self, authorizer_appid, authorizer_refresh_token): """ 获取(刷新)授权公众号的令牌 :params authorizer_appid: 授权方appid :params authorizer_refresh_token: 授权方的刷新令牌 """ return self.post( '/component/api_authorizer_token', ...
获取授权方的选项设置信息 :params authorizer_appid: 授权公众号appid :params option_name: 选项名称
def get_authorizer_option(self, authorizer_appid, option_name): """ 获取授权方的选项设置信息 :params authorizer_appid: 授权公众号appid :params option_name: 选项名称 """ return self.post( '/component/api_get_authorizer_option', data={ 'component_appid':...
设置授权方的选项信息 :params authorizer_appid: 授权公众号appid :params option_name: 选项名称 :params option_value: 设置的选项值
def set_authorizer_option( self, authorizer_appid, option_name, option_value): """ 设置授权方的选项信息 :params authorizer_appid: 授权公众号appid :params option_name: 选项名称 :params option_value: 设置的选项值 """ return self.post( '/component/api_set_authorizer_...
通过授权码直接获取 Client 对象 :params authorization_code: 授权code,会在授权成功时返回给第三方平台,详见第三方平台授权流程说明
def get_client_by_authorization_code(self, authorization_code): """ 通过授权码直接获取 Client 对象 :params authorization_code: 授权code,会在授权成功时返回给第三方平台,详见第三方平台授权流程说明 """ warnings.warn('`get_client_by_authorization_code` method of `WeChatComponent` is deprecated,' 'Use `...
通过 authorizer_appid 获取 Client 对象 :params authorizer_appid: 授权公众号appid
def get_client_by_appid(self, authorizer_appid): """ 通过 authorizer_appid 获取 Client 对象 :params authorizer_appid: 授权公众号appid """ access_token_key = '{0}_access_token'.format(authorizer_appid) refresh_token_key = '{0}_refresh_token'.format(authorizer_appid) access_t...
处理 wechat server 推送消息 :params msg: 加密内容 :params msg_signature: 消息签名 :params timestamp: 时间戳 :params nonce: 随机数
def parse_message(self, msg, msg_signature, timestamp, nonce): """ 处理 wechat server 推送消息 :params msg: 加密内容 :params msg_signature: 消息签名 :params timestamp: 时间戳 :params nonce: 随机数 """ content = self.crypto.decrypt_message(msg, msg_signature, timestamp, nonce...
处理 wechat server 推送的 component_verify_ticket消息 :params msg: 加密内容 :params signature: 消息签名 :params timestamp: 时间戳 :params nonce: 随机数
def cache_component_verify_ticket(self, msg, signature, timestamp, nonce): """ 处理 wechat server 推送的 component_verify_ticket消息 :params msg: 加密内容 :params signature: 消息签名 :params timestamp: 时间戳 :params nonce: 随机数 """ warnings.warn('`cache_component_verify_ti...
处理取消授权通知 :params msg: 加密内容 :params signature: 消息签名 :params timestamp: 时间戳 :params nonce: 随机数
def get_unauthorized(self, msg, signature, timestamp, nonce): """ 处理取消授权通知 :params msg: 加密内容 :params signature: 消息签名 :params timestamp: 时间戳 :params nonce: 随机数 """ warnings.warn('`get_unauthorized` method of `WeChatComponent` is deprecated,' ...
获取 access_token :param code: 授权完成跳转回来后 URL 中的 code 参数 :return: JSON 数据包
def fetch_access_token(self, code): """获取 access_token :param code: 授权完成跳转回来后 URL 中的 code 参数 :return: JSON 数据包 """ res = self._get( 'sns/oauth2/component/access_token', params={ 'appid': self.app_id, 'component_appid': self...
获取用户基本信息(需授权作用域为snsapi_userinfo) 如果网页授权作用域为snsapi_userinfo,则此时开发者可以通过access_token和openid拉取用户信息了。 :param openid: 可选,微信 openid,默认获取当前授权用户信息 :param access_token: 可选,access_token,默认使用当前授权用户的 access_token :param lang: 可选,语言偏好, 默认为 ``zh_CN`` :return: JSON 数据包
def get_user_info(self, openid=None, access_token=None, lang='zh_CN'): """ 获取用户基本信息(需授权作用域为snsapi_userinfo) 如果网页授权作用域为snsapi_userinfo,则此时开发者可以通过access_token和openid拉取用户信息了。 :param openid: 可选,微信 openid,默认获取当前授权用户信息 :param access_token: 可选,access_token,默认使用当前授权用户的 access_token :pa...
获取授权跳转地址 :return: URL 地址
def authorize_url(self): """获取授权跳转地址 :return: URL 地址 """ redirect_uri = quote(self.redirect_uri, safe=b'') url_list = [ self.OAUTH_BASE_URL, 'oauth2/authorize?appid=', self.app_id, '&redirect_uri=', redirect_uri, ...
获取 access_token :param code: 授权完成跳转回来后 URL 中的 code 参数 :return: JSON 数据包
def fetch_access_token(self, code): """获取 access_token :param code: 授权完成跳转回来后 URL 中的 code 参数 :return: JSON 数据包 """ res = self._get( 'sns/oauth2/access_token', params={ 'appid': self.app_id, 'secret': self.secret, ...
刷新 access token :param refresh_token: OAuth2 refresh token :return: JSON 数据包
def refresh_access_token(self, refresh_token): """刷新 access token :param refresh_token: OAuth2 refresh token :return: JSON 数据包 """ res = self._get( 'sns/oauth2/refresh_token', params={ 'appid': self.app_id, 'grant_type': 'r...
检查 access_token 有效性 :param openid: 可选,微信 openid,默认获取当前授权用户信息 :param access_token: 可选,access_token,默认使用当前授权用户的 access_token :return: 有效返回 True,否则 False
def check_access_token(self, openid=None, access_token=None): """检查 access_token 有效性 :param openid: 可选,微信 openid,默认获取当前授权用户信息 :param access_token: 可选,access_token,默认使用当前授权用户的 access_token :return: 有效返回 True,否则 False """ openid = openid or self.open_id access_toke...
新增其它类型永久素材 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%8A%E4%BC%A0%E6%B0%B8%E4%B9%85%E7%B4%A0%E6%9D%90 :param agent_id: 企业应用的id :param media_type: 媒体文件类型,分别有图片(image)、语音(voice)、视频(video)普通文件(file) :param media_file: 要上传的文件,一个 File-object :return: 返回的 JS...
def add(self, agent_id, media_type, media_file): """ 新增其它类型永久素材 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%8A%E4%BC%A0%E6%B0%B8%E4%B9%85%E7%B4%A0%E6%9D%90 :param agent_id: 企业应用的id :param media_type: 媒体文件类型,分别有图片(image)、语音(voice)、视频(video)普通文件(file) ...
获取永久素材下载地址 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E6%B0%B8%E4%B9%85%E7%B4%A0%E6%9D%90 :param agent_id: 企业应用的id :param media_id: 媒体文件 ID :return: 临时素材下载地址
def get_url(self, agent_id, media_id): """ 获取永久素材下载地址 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E6%B0%B8%E4%B9%85%E7%B4%A0%E6%9D%90 :param agent_id: 企业应用的id :param media_id: 媒体文件 ID :return: 临时素材下载地址 """ parts = ( ...
获取永久素材 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E6%B0%B8%E4%B9%85%E7%B4%A0%E6%9D%90 :param agent_id: 企业应用的id :param media_id: 媒体文件 ID :return: requests 的 Response 实例
def get(self, agent_id, media_id): """ 获取永久素材 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E6%B0%B8%E4%B9%85%E7%B4%A0%E6%9D%90 :param agent_id: 企业应用的id :param media_id: 媒体文件 ID :return: requests 的 Response 实例 """ retur...
修改永久图文素材 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=%E4%BF%AE%E6%94%B9%E6%B0%B8%E4%B9%85%E5%9B%BE%E6%96%87%E7%B4%A0%E6%9D%90 :param media_id: 要修改的图文消息的 id :param index: 要更新的文章在图文消息中的位置(多图文消息时,此字段才有意义),第一篇为 0 :param articles: 图文素材数组 :return: 返回的 JSON 数据包
def update_articles(self, agent_id, media_id, articles): """ 修改永久图文素材 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=%E4%BF%AE%E6%94%B9%E6%B0%B8%E4%B9%85%E5%9B%BE%E6%96%87%E7%B4%A0%E6%9D%90 :param media_id: 要修改的图文消息的 id :param index: 要更新的文章在图文消息中的位置(多图文消息时,此字段才有意...
创建菜单 https://work.weixin.qq.com/api/doc#90000/90135/90231 :param agent_id: 应用id
def create(self, agent_id, menu_data): """ 创建菜单 https://work.weixin.qq.com/api/doc#90000/90135/90231 :param agent_id: 应用id """ return self._post( 'menu/create', params={ 'agentid': agent_id }, data=menu_dat...
批量获取永久素材列表 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E7%B4%A0%E6%9D%90%E5%88%97%E8%A1%A8 :param agent_id: 企业应用的id :param media_type: 媒体文件类型,分别有图文(mpnews)、图片(image)、 语音(voice)、视频(video)和文件(file) :param offset: 从全部素材的该偏移位置...
def batchget(self, agent_id, media_type, offset=0, count=20): """ 批量获取永久素材列表 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E7%B4%A0%E6%9D%90%E5%88%97%E8%A1%A8 :param agent_id: 企业应用的id :param media_type: 媒体文件类型,分别有图文(mpnews)、图片(image)、 ...
获取微信 JS-SDK ticket 该方法会通过 session 对象自动缓存管理 ticket :return: ticket
def get_jsapi_ticket(self): """ 获取微信 JS-SDK ticket 该方法会通过 session 对象自动缓存管理 ticket :return: ticket """ ticket_key = '{0}_jsapi_ticket'.format(self.appid) expires_at_key = '{0}_jsapi_ticket_expires_at'.format(self.appid) ticket = self.session.get(ticket_ke...
获取 api_ticket:是用于调用微信卡券JS API的临时票据,有效期为7200 秒,通过access_token 来获取。 微信文档地址:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html 该方法会通过 session 对象自动缓存管理 ticket :return: ticket
def get_jsapi_card_ticket(self): """ 获取 api_ticket:是用于调用微信卡券JS API的临时票据,有效期为7200 秒,通过access_token 来获取。 微信文档地址:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html 该方法会通过 session 对象自动缓存管理 ticket :return: ticket """ jsapi_card_ticket_key = '{0}_jsap...
参数意义见微信文档地址:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html :param card_ticket: 用于卡券的微信 api_ticket :param card_type: :param kwargs: 非必须参数:noncestr, timestamp, code, openid, fixed_begintimestamp, outer_str :return: 包含调用jssdk所有所需参数的 dict
def get_jsapi_card_params(self, card_ticket, card_type, **kwargs): """ 参数意义见微信文档地址:http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html :param card_ticket: 用于卡券的微信 api_ticket :param card_type: :param kwargs: 非必须参数:noncestr, timestamp, code, openid, fixed_begintim...
创建发票卡券模板 注意这里的对象和会员卡有类似之处,但是含义有不同。创建发票卡券模板是创建发票卡券的基础。 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1496561481_1TyO7 :param base_info:发票卡券模板基础信息 :type base_info: dict :param payee: 收款方(开票方)全称,显示在发票详情内。建议一个收款方对应一个发票卡券模板 :param invoice_type: 发票类型描述 :param detail...
def create_card(self, base_info, payee, invoice_type, detail=None): """ 创建发票卡券模板 注意这里的对象和会员卡有类似之处,但是含义有不同。创建发票卡券模板是创建发票卡券的基础。 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1496561481_1TyO7 :param base_info:发票卡券模板基础信息 :type base_info: dict :param payee: 收款方(开票方...
获取授权页链接 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2 :param s_pappid: 开票平台在微信的标识号,商户需要找开票平台提供 :param order_id: 订单id,在商户内单笔开票请求的唯一识别号 :param money: 订单金额,以分为单位 :type money: int :param timestamp: Unix 时间戳 :type timestamp: int :param sour...
def get_auth_url(self, s_pappid, order_id, money, timestamp, source, ticket, auth_type, redirect_url=None): """ 获取授权页链接 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2 :param s_pappid: 开票平台在微信的标识号,商户需要找开票平台提供 :param order_id: 订单id,在商户内单笔开票请求的唯一识别号 :para...
设置授权页字段信息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2 :param user_field: 授权页个人发票字段 :type user_field: dict :param biz_field: 授权页单位发票字段 :type biz_field: dict
def set_auth_field(self, user_field, biz_field): """ 设置授权页字段信息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2 :param user_field: 授权页个人发票字段 :type user_field: dict :param biz_field: 授权页单位发票字段 :type biz_field: dict """ return self....
拒绝用户的开发票请求 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2 :param s_pappid: 开票平台在微信的标识号,商户需要找开票平台提供 :param order_id: 订单id,在商户内单笔开票请求的唯一识别号 :param reason: 拒绝原因 :param redirect_url: 跳转链接
def reject_insert(self, s_pappid, order_id, reason, redirect_url=None): """ 拒绝用户的开发票请求 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2 :param s_pappid: 开票平台在微信的标识号,商户需要找开票平台提供 :param order_id: 订单id,在商户内单笔开票请求的唯一识别号 :param reason: 拒绝原因 :param red...
上传电子发票中的消费凭证 PDF 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2 :param pdf: 要上传的 PDF 文件,一个 File-object :return: 64位整数,在将发票卡券插入用户卡包时使用用于关联pdf和发票卡券。有效期为3天。
def upload_pdf(self, pdf): """ 上传电子发票中的消费凭证 PDF 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2 :param pdf: 要上传的 PDF 文件,一个 File-object :return: 64位整数,在将发票卡券插入用户卡包时使用用于关联pdf和发票卡券。有效期为3天。 """ return self._post( 'platform/setpdf', ...
更新发票卡券的状态 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2 :param card_id: 发票卡券模板的编号 :param code: 发票卡券的编号 :param reimburse_status: 发票报销状态
def update_status(self, card_id, code, reimburse_status): """ 更新发票卡券的状态 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1497082828_r1cI2 :param card_id: 发票卡券模板的编号 :param code: 发票卡券的编号 :param reimburse_status: 发票报销状态 """ return self._post( 'pl...
关联商户号与开票平台,设置支付后开票 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1496561731_2Z55U :param mchid: 微信支付商户号 :param s_pappid: 开票平台在微信的标识号,商户需要找开票平台提供
def set_pay_mch(self, mchid, s_pappid): """ 关联商户号与开票平台,设置支付后开票 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1496561731_2Z55U :param mchid: 微信支付商户号 :param s_pappid: 开票平台在微信的标识号,商户需要找开票平台提供 """ return self._post( 'setbizattr', params={ ...
报销方更新发票信息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1496561749_f7T6D :param card_id: 发票卡券的 Card ID :param encrypt_code: 发票卡券的加密 Code :param reimburse_status: 发票报销状态
def update_reimburse(self, card_id, encrypt_code, reimburse_status): """ 报销方更新发票信息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1496561749_f7T6D :param card_id: 发票卡券的 Card ID :param encrypt_code: 发票卡券的加密 Code :param reimburse_status: 发票报销状态 """ return...
报销方批量更新发票信息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1496561749_f7T6D :param openid: 用户的 Open ID :param reimburse_status: 发票报销状态 :param invoice_list: 发票列表 :type invoice_list: list[dict]
def batch_update_reimburse(self, openid, reimburse_status, invoice_list): """ 报销方批量更新发票信息 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1496561749_f7T6D :param openid: 用户的 Open ID :param reimburse_status: 发票报销状态 :param invoice_list: 发票列表 :type invoice_list: li...
获取添加发票链接 获取链接,发送给用户。用户同意以后,发票抬头信息将会录入到用户微信中 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1496554912_vfWU0 :param user_fill: 企业设置抬头为0,用户自己填写抬头为1 :type user_fill: bool :param title: 抬头,当 user_fill 为 False 时必填 :param phone: 联系方式 :param tax_no: 税号 :param ...
def get_user_title_url( self, user_fill, title=None, phone=None, tax_no=None, addr=None, bank_type=None, bank_no=None, out_title_id=None): """ 获取添加发票链接 获取链接,发送给用户。用户同意以后,发票抬头信息将会录入到用户微信中 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1496554912_vfWU0 :p...
获取商户专属开票链接 商户调用接口,获取链接。用户扫码,可以选择抬头发给商户。可以将链接转成二维码,立在收银台。 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1496554912_vfWU0 :param attach: 附加字段,用户提交发票时会发送给商户 :return: 商户专属开票链接
def get_select_title_url(self, attach=None): """ 获取商户专属开票链接 商户调用接口,获取链接。用户扫码,可以选择抬头发给商户。可以将链接转成二维码,立在收银台。 详情请参考 https://mp.weixin.qq.com/wiki?id=mp1496554912_vfWU0 :param attach: 附加字段,用户提交发票时会发送给商户 :return: 商户专属开票链接 """ return self._post( ...
上传临时素材 详情请参考 http://mp.weixin.qq.com/wiki/5/963fc70b80dc75483a271298a76a8d59.html :param media_type: 媒体文件类型,分别有图片(image)、语音(voice)、视频(video)和缩略图(thumb) :param media_file: 要上传的文件,一个 File-object :return: 返回的 JSON 数据包
def upload(self, media_type, media_file): """ 上传临时素材 详情请参考 http://mp.weixin.qq.com/wiki/5/963fc70b80dc75483a271298a76a8d59.html :param media_type: 媒体文件类型,分别有图片(image)、语音(voice)、视频(video)和缩略图(thumb) :param media_file: 要上传的文件,一个 File-object :return: 返回的 JSON 数据包 ...
群发视频消息时获取视频 media_id 详情请参考 http://mp.weixin.qq.com/wiki/15/5380a4e6f02f2ffdc7981a8ed7a40753.html :param media_id: 需通过基础支持中的上传下载多媒体文件 :func:`upload` 来得到 :param title: 视频标题 :param description: 视频描述 :return: 返回的 JSON 数据包
def upload_video(self, media_id, title, description): """ 群发视频消息时获取视频 media_id 详情请参考 http://mp.weixin.qq.com/wiki/15/5380a4e6f02f2ffdc7981a8ed7a40753.html :param media_id: 需通过基础支持中的上传下载多媒体文件 :func:`upload` 来得到 :param title: 视频标题 :param description: 视频描述 ...
上传群发消息内的图片 详情请参考 http://mp.weixin.qq.com/wiki/15/5380a4e6f02f2ffdc7981a8ed7a40753.html :param media_file: 要上传的文件,一个 File-object :return: 上传成功时返回图片 URL
def upload_image(self, media_file): """ 上传群发消息内的图片 详情请参考 http://mp.weixin.qq.com/wiki/15/5380a4e6f02f2ffdc7981a8ed7a40753.html :param media_file: 要上传的文件,一个 File-object :return: 上传成功时返回图片 URL """ res = self._post( url='media/uploadimg', ...
rsa 加密 :param data: 待加密字符串/binary :param pem: RSA public key 内容/binary :param b64_encode: 是否对输出进行 base64 encode :return: 如果 b64_encode=True 的话,返回加密并 base64 处理后的 string;否则返回加密后的 binary
def rsa_encrypt(data, pem, b64_encode=True): """ rsa 加密 :param data: 待加密字符串/binary :param pem: RSA public key 内容/binary :param b64_encode: 是否对输出进行 base64 encode :return: 如果 b64_encode=True 的话,返回加密并 base64 处理后的 string;否则返回加密后的 binary """ from cryptography.hazmat.backends import default_ba...
rsa 解密 :param encrypted_data: 待解密 bytes :param pem: RSA private key 内容/binary :param password: RSA private key pass phrase :return: 解密后的 binary
def rsa_decrypt(encrypted_data, pem, password=None): """ rsa 解密 :param encrypted_data: 待解密 bytes :param pem: RSA private key 内容/binary :param password: RSA private key pass phrase :return: 解密后的 binary """ from cryptography.hazmat.backends import default_backend from cryptography.hazm...
发送现金红包 :param user_id: 接收红包的用户在公众号下的 openid :param total_amount: 红包金额,单位分 :param send_name: 商户名称 :param act_name: 活动名称 :param wishing: 红包祝福语 :param remark: 备注 :param client_ip: 可选,调用接口的机器 IP 地址 :param total_num: 可选,红包发放总人数,默认为 1 :param out_trade_n...
def send(self, user_id, total_amount, send_name, act_name, wishing, remark, total_num=1, client_ip=None, out_trade_no=None, scene_id=None, consume_mch_id=None): """ 发送现金红包 :param user_id: 接收红包的用户在公众号下的 openid :param total_amount: 红包金额,单位分 :param send_na...
查询红包发放记录 :param out_trade_no: 商户订单号 :param bill_type: 可选,订单类型,目前固定为 MCHT :return: 返回的红包发放记录信息
def query(self, out_trade_no, bill_type='MCHT'): """ 查询红包发放记录 :param out_trade_no: 商户订单号 :param bill_type: 可选,订单类型,目前固定为 MCHT :return: 返回的红包发放记录信息 """ data = { 'mch_billno': out_trade_no, 'bill_type': bill_type, 'appid': self.a...
创建会话 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=企业会话接口说明 :param chat_id: 会话id。字符串类型,最长32个字符。只允许字符0-9及字母a-zA-Z, 如果值内容为64bit无符号整型:要求值范围在[1, 2^63)之间, [2^63, 2^64)为系统分配会话id区间 :param name: 会话标题 :param owner: 管理员userid,必须是该会...
def create(self, chat_id, name, owner, user_list): """ 创建会话 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=企业会话接口说明 :param chat_id: 会话id。字符串类型,最长32个字符。只允许字符0-9及字母a-zA-Z, 如果值内容为64bit无符号整型:要求值范围在[1, 2^63)之间, [2^63, 2^64)为系统分...
修改会话 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=企业会话接口说明 :param chat_id: 会话 ID :param op_user: 操作人 userid :param name: 会话标题 :param owner: 管理员userid,必须是该会话userlist的成员之一 :param add_user_list: 会话新增成员列表,成员用userid来标识 :param del_user_list: 会话退出成员列表...
def update(self, chat_id, op_user, name=None, owner=None, add_user_list=None, del_user_list=None): """ 修改会话 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=企业会话接口说明 :param chat_id: 会话 ID :param op_user: 操作人 userid :param name: 会话标题 ...
清除会话未读状态 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=企业会话接口说明 :param op_user: 会话所有者的userid :param type: 会话类型:single|group,分别表示:单聊|群聊 :param id: 会话值,为userid|chatid,分别表示:成员id|会话id :return: 返回的 JSON 数据包
def clear_notify(self, op_user, type, id): """ 清除会话未读状态 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=企业会话接口说明 :param op_user: 会话所有者的userid :param type: 会话类型:single|group,分别表示:单聊|群聊 :param id: 会话值,为userid|chatid,分别表示:成员id|会话id :return: 返回的 JSON ...
发送文本消息 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=企业会话接口说明 :param sender: 发送人 :param receiver_type: 接收人类型:single|group,分别表示:单聊|群聊 :param receiver_id: 接收人的值,为userid|chatid,分别表示:成员id|会话id :param content: 消息内容 :return: 返回的 JSON 数据包
def send_text(self, sender, receiver_type, receiver_id, content): """ 发送文本消息 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=企业会话接口说明 :param sender: 发送人 :param receiver_type: 接收人类型:single|group,分别表示:单聊|群聊 :param receiver_id: 接收人的值,为userid|chatid,分别表示:成员id...
发送单聊文本消息 :param sender: 发送人 :param receiver: 接收人成员 ID :param content: 消息内容 :return: 返回的 JSON 数据包
def send_single_text(self, sender, receiver, content): """ 发送单聊文本消息 :param sender: 发送人 :param receiver: 接收人成员 ID :param content: 消息内容 :return: 返回的 JSON 数据包 """ return self.send_text(sender, 'single', receiver, content)
发送群聊文本消息 :param sender: 发送人 :param receiver: 会话 ID :param content: 消息内容 :return: 返回的 JSON 数据包
def send_group_text(self, sender, receiver, content): """ 发送群聊文本消息 :param sender: 发送人 :param receiver: 会话 ID :param content: 消息内容 :return: 返回的 JSON 数据包 """ return self.send_text(sender, 'group', receiver, content)
发送图片消息 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=企业会话接口说明 :param sender: 发送人 :param receiver_type: 接收人类型:single|group,分别表示:单聊|群聊 :param receiver_id: 接收人的值,为userid|chatid,分别表示:成员id|会话id :param media_id: 图片媒体文件id,可以调用上传素材文件接口获取 :return: 返回的 JSON 数据包
def send_image(self, sender, receiver_type, receiver_id, media_id): """ 发送图片消息 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=企业会话接口说明 :param sender: 发送人 :param receiver_type: 接收人类型:single|group,分别表示:单聊|群聊 :param receiver_id: 接收人的值,为userid|chatid,分别表示:成员...
发送单聊图片消息 :param sender: 发送人 :param receiver: 接收人成员 ID :param media_id: 图片媒体文件id,可以调用上传素材文件接口获取 :return: 返回的 JSON 数据包
def send_single_image(self, sender, receiver, media_id): """ 发送单聊图片消息 :param sender: 发送人 :param receiver: 接收人成员 ID :param media_id: 图片媒体文件id,可以调用上传素材文件接口获取 :return: 返回的 JSON 数据包 """ return self.send_image(sender, 'single', receiver, media_id)
发送群聊图片消息 :param sender: 发送人 :param receiver: 会话 ID :param media_id: 图片媒体文件id,可以调用上传素材文件接口获取 :return: 返回的 JSON 数据包
def send_group_image(self, sender, receiver, media_id): """ 发送群聊图片消息 :param sender: 发送人 :param receiver: 会话 ID :param media_id: 图片媒体文件id,可以调用上传素材文件接口获取 :return: 返回的 JSON 数据包 """ return self.send_image(sender, 'group', receiver, media_id)
发送文件消息 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=企业会话接口说明 :param sender: 发送人 :param receiver_type: 接收人类型:single|group,分别表示:单聊|群聊 :param receiver_id: 接收人的值,为userid|chatid,分别表示:成员id|会话id :param media_id: 文件id,可以调用上传素材文件接口获取, 文件须大于4字节 :return: 返回的 JSON...
def send_file(self, sender, receiver_type, receiver_id, media_id): """ 发送文件消息 详情请参考 https://qydev.weixin.qq.com/wiki/index.php?title=企业会话接口说明 :param sender: 发送人 :param receiver_type: 接收人类型:single|group,分别表示:单聊|群聊 :param receiver_id: 接收人的值,为userid|chatid,分别表示:成员i...
发送单聊文件消息 :param sender: 发送人 :param receiver: 接收人成员 ID :param media_id: 文件id,可以调用上传素材文件接口获取, 文件须大于4字节 :return: 返回的 JSON 数据包
def send_single_file(self, sender, receiver, media_id): """ 发送单聊文件消息 :param sender: 发送人 :param receiver: 接收人成员 ID :param media_id: 文件id,可以调用上传素材文件接口获取, 文件须大于4字节 :return: 返回的 JSON 数据包 """ return self.send_file(sender, 'single', receiver, media_id)
发送群聊文件消息 :param sender: 发送人 :param receiver: 会话 ID :param media_id: 文件id,可以调用上传素材文件接口获取, 文件须大于4字节 :return: 返回的 JSON 数据包
def send_group_file(self, sender, receiver, media_id): """ 发送群聊文件消息 :param sender: 发送人 :param receiver: 会话 ID :param media_id: 文件id,可以调用上传素材文件接口获取, 文件须大于4字节 :return: 返回的 JSON 数据包 """ return self.send_file(sender, 'group', receiver, media_id)
发放代金券 :param user_id: 用户在公众号下的 openid :param stock_id: 代金券批次 ID :param op_user_id: 可选,操作员账号,默认为商户号 :param device_info: 可选,微信支付分配的终端设备号 :param out_trade_no: 可选,商户订单号,需保持唯一性,默认自动生成 :return: 返回的结果信息
def send(self, user_id, stock_id, op_user_id=None, device_info=None, out_trade_no=None): """ 发放代金券 :param user_id: 用户在公众号下的 openid :param stock_id: 代金券批次 ID :param op_user_id: 可选,操作员账号,默认为商户号 :param device_info: 可选,微信支付分配的终端设备号 :param out_trade_no: 可...
查询代金券批次 :param stock_id: 代金券批次 ID :param op_user_id: 可选,操作员账号,默认为商户号 :param device_info: 可选,微信支付分配的终端设备号 :return: 返回的结果信息
def query_stock(self, stock_id, op_user_id=None, device_info=None): """ 查询代金券批次 :param stock_id: 代金券批次 ID :param op_user_id: 可选,操作员账号,默认为商户号 :param device_info: 可选,微信支付分配的终端设备号 :return: 返回的结果信息 """ data = { 'appid': self.appid, 'co...
查询代金券信息 :param coupon_id: 代金券 ID :param user_id: 用户在公众号下的 openid :param op_user_id: 可选,操作员账号,默认为商户号 :param device_info: 可选,微信支付分配的终端设备号 :return: 返回的结果信息
def query_coupon(self, coupon_id, user_id, op_user_id=None, device_info=None): """ 查询代金券信息 :param coupon_id: 代金券 ID :param user_id: 用户在公众号下的 openid :param op_user_id: 可选,操作员账号,默认为商户号 :param device_info: 可选,微信支付分配的终端设备号 :return: 返回的结果信息 ...
创建数据源 https://wximg.qq.com/wxp/pdftool/get.html?id=rkalQXDBM&pa=39 :param _type: 用户行为源类型 :param name: 用户行为源名称 必填 :param description: 用户行为源描述,字段长度最小 1 字节,长度最大 128 字节 :param version: 版本号 v1.0 :return: 数据源唯一ID
def add_user_action_sets(self, _type, name, description, version='v1.0'): """ 创建数据源 https://wximg.qq.com/wxp/pdftool/get.html?id=rkalQXDBM&pa=39 :param _type: 用户行为源类型 :param name: 用户行为源名称 必填 :param description: 用户行为源描述,字段长度最小 1 字节,长度最大 128 字节 :param version: 版本号 ...
获取数据源信息 :param user_action_set_id: 数据源唯一ID :param version: 版本号 v1.0
def get_user_action_sets(self, user_action_set_id, version='v1.0'): """ 获取数据源信息 :param user_action_set_id: 数据源唯一ID :param version: 版本号 v1.0 """ return self._get( 'user_action_sets/get', params={'version': version, 'user_action_set_id': user_action...
回传数据 https://wximg.qq.com/wxp/pdftool/get.html?id=rkalQXDBM&pa=39 :param actions: 用户行为源类型 :param version: 版本号 v1.0
def add_user_actions(self, actions=(), version='v1.0'): """ 回传数据 https://wximg.qq.com/wxp/pdftool/get.html?id=rkalQXDBM&pa=39 :param actions: 用户行为源类型 :param version: 版本号 v1.0 """ return self._post( 'user_actions/add', params={'version': v...
获取朋友圈销售线索数据接口 :param start_date: 开始日期 默认今天 :param end_date: 结束日期 默认今天 :param filtering: 过滤条件 [{field: 过滤字段, operator: 操作符, values: 字段取值}] :param page: 页码,获取指定页数据 :param page_size: 一页获取的数据条数(1-100) :param version: 版本号 v1.0
def get_ad_leads(self, start_date=None, end_date=None, filtering=(), page=1, page_size=100, version='v1.0'): """ 获取朋友圈销售线索数据接口 :param start_date: 开始日期 默认今天 :param end_date: 结束日期 默认今天 :param filtering: 过滤条件 [{field: 过滤字段, operator: 操作符, values: 字段取值}] :param page: 页码,获取指...
统一下单接口 :param trade_type: 交易类型,取值如下:JSAPI,NATIVE,APP,WAP, MWEB :param body: 商品描述 :param total_fee: 总金额,单位分 :param notify_url: 接收微信支付异步通知回调地址 :param client_ip: 可选,APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP :param user_id: 可选,用户在商户appid下的唯一标识。trade_type=JSAPI和appid已设定,此参数必传 ...
def create(self, trade_type, body, total_fee, notify_url, client_ip=None, user_id=None, out_trade_no=None, detail=None, attach=None, fee_type='CNY', time_start=None, time_expire=None, goods_tag=None, product_id=None, device_info=None, limit_pay=None, scene_info=None, sub_use...
关闭订单 :param out_trade_no: 商户系统内部的订单号 :return: 返回的结果数据
def close(self, out_trade_no): """ 关闭订单 :param out_trade_no: 商户系统内部的订单号 :return: 返回的结果数据 """ data = { 'appid': self.appid, 'out_trade_no': out_trade_no, } return self._post('pay/closeorder', data=data)
获取 APP 支付参数 :param prepay_id: 统一下单接口返回的 prepay_id 参数值 :param timestamp: 可选,时间戳,默认为当前时间戳 :param nonce_str: 可选,随机字符串,默认自动生成 :return: 签名
def get_appapi_params(self, prepay_id, timestamp=None, nonce_str=None): """ 获取 APP 支付参数 :param prepay_id: 统一下单接口返回的 prepay_id 参数值 :param timestamp: 可选,时间戳,默认为当前时间戳 :param nonce_str: 可选,随机字符串,默认自动生成 :return: 签名 """ data = { 'appid': self.appid,...
撤销订单 :param transaction_id: 可选,微信的订单号,优先使用 :param out_trade_no: 可选,商户系统内部的订单号, transaction_id、out_trade_no二选一, 如果同时存在优先级:transaction_id> out_trade_no :return: 返回的结果数据
def reverse(self, transaction_id=None, out_trade_no=None): """ 撤销订单 :param transaction_id: 可选,微信的订单号,优先使用 :param out_trade_no: 可选,商户系统内部的订单号, transaction_id、out_trade_no二选一, 如果同时存在优先级:transaction_id> out_trade_no :return: 返...
获取用户基本信息(包括UnionID机制) 详情请参考 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839 :param user_id: 普通用户的标识,对当前公众号唯一 :param lang: 返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语 :return: 返回的 JSON 数据包 使用示例:: from wechatpy import WeChatClient client...
def get(self, user_id, lang='zh_CN'): """ 获取用户基本信息(包括UnionID机制) 详情请参考 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839 :param user_id: 普通用户的标识,对当前公众号唯一 :param lang: 返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语 :return: 返回的 JSON 数据包 使用示例:: ...
获取一页用户列表(当关注用户过多的情况下,这个接口只会返回一部分用户) 详情请参考 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840 :param first_user_id: 可选。第一个拉取的 OPENID,不填默认从头开始拉取 :return: 返回的 JSON 数据包 使用示例:: from wechatpy import WeChatClient client = WeChatClient('appid',...
def get_followers(self, first_user_id=None): """ 获取一页用户列表(当关注用户过多的情况下,这个接口只会返回一部分用户) 详情请参考 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840 :param first_user_id: 可选。第一个拉取的 OPENID,不填默认从头开始拉取 :return: 返回的 JSON 数据包 使用示例:: from wechatp...
获取所有的用户openid列表 详情请参考 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840 :return: 返回一个迭代器,可以用for进行循环,得到openid 使用示例:: from wechatpy import WeChatClient client = WeChatClient('appid', 'secret') for openid in client.user.iter_followers...
def iter_followers(self, first_user_id=None): """ 获取所有的用户openid列表 详情请参考 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840 :return: 返回一个迭代器,可以用for进行循环,得到openid 使用示例:: from wechatpy import WeChatClient client = WeChatClient('appi...
获取用户所在分组 ID 详情请参考 http://mp.weixin.qq.com/wiki/0/56d992c605a97245eb7e617854b169fc.html :param user_id: 用户 ID :return: 用户所在分组 ID 使用示例:: from wechatpy import WeChatClient client = WeChatClient('appid', 'secret') group_id = client.user.get_gr...
def get_group_id(self, user_id): """ 获取用户所在分组 ID 详情请参考 http://mp.weixin.qq.com/wiki/0/56d992c605a97245eb7e617854b169fc.html :param user_id: 用户 ID :return: 用户所在分组 ID 使用示例:: from wechatpy import WeChatClient client = WeChatClient('appid'...
批量获取用户基本信息 开发者可通过该接口来批量获取用户基本信息。最多支持一次拉取100条。 详情请参考 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839 :param user_list: user_list,支持“使用示例”中两种输入格式 :return: 用户信息的 list 使用示例:: from wechatpy import WeChatClient client = WeChatClien...
def get_batch(self, user_list): """ 批量获取用户基本信息 开发者可通过该接口来批量获取用户基本信息。最多支持一次拉取100条。 详情请参考 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839 :param user_list: user_list,支持“使用示例”中两种输入格式 :return: 用户信息的 list 使用示例:: from wechatpy i...
微信公众号主体变更迁移用户 openid 详情请参考 http://kf.qq.com/faq/170221aUnmmU170221eUZJNf.html :param from_appid: 原公众号的 appid :param openid_list: 需要转换的openid,这些必须是旧账号目前关注的才行,否则会出错;一次最多100个 :return: 转换后的 openid 信息列表
def change_openid(self, from_appid, openid_list): '''微信公众号主体变更迁移用户 openid 详情请参考 http://kf.qq.com/faq/170221aUnmmU170221eUZJNf.html :param from_appid: 原公众号的 appid :param openid_list: 需要转换的openid,这些必须是旧账号目前关注的才行,否则会出错;一次最多100个 :return: 转换后的 openid 信息列表 ''' ...