INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
更新卡券 code | def update_code(self, card_id, old_code, new_code):
"""
更新卡券 code
"""
return self._post(
'card/code/update',
data={
'card_id': card_id,
'code': old_code,
'new_code': new_code
}
) |
设置卡券失效 | def invalid_code(self, code, card_id=None):
"""
设置卡券失效
"""
card_data = {
'code': code
}
if card_id:
card_data['card_id'] = card_id
return self._post(
'card/code/unavailable',
data=card_data
) |
激活会员卡 - 接口激活方式 详情请参见 https:// mp. weixin. qq. com/ wiki?t = resource/ res_main&id = mp1451025283 | def activate_membercard(self, membership_number, code, **kwargs):
"""
激活会员卡 - 接口激活方式
详情请参见
https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025283
参数示例:
{
"init_bonus": 100,
"init_bonus_record":"旧积分同步",
"init_balance": 200,
... |
更新会员信息 详情请参见 https:// mp. weixin. qq. com/ wiki?t = resource/ res_main&id = mp1451025283 | def update_membercard(self, code, card_id, **kwargs):
"""
更新会员信息
详情请参见
https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025283
注意事项:
1.开发者可以同时传入add_bonus和bonus解决由于同步失败带来的幂等性问题。同时传入add_bonus和bonus时
add_bonus作为积分变动消息中的变量值,而bonus作为卡面上的总积分额度显示。余额变动同理。
... |
新增支付后投放卡券的规则,支持支付后领卡,支付后赠券 详情请参见 https:// mp. weixin. qq. com/ wiki?id = mp1466494654_K9rNz | def add_pay_giftcard(self, base_info, extra_info, is_membercard):
"""
新增支付后投放卡券的规则,支持支付后领卡,支付后赠券
详情请参见
https://mp.weixin.qq.com/wiki?id=mp1466494654_K9rNz
:param base_info: 营销规则结构体
:type base_info: dict
:param extra_info: 支付规则结构体
:type extra_info: dict
... |
查询支付后投放卡券的规则 详情请参见 https:// mp. weixin. qq. com/ wiki?id = mp1466494654_K9rNz | def get_pay_giftcard(self, rule_id):
"""
查询支付后投放卡券的规则
详情请参见
https://mp.weixin.qq.com/wiki?id=mp1466494654_K9rNz
:param rule_id: 支付即会员的规则 ID
:return: 支付后投放卡券的规则
:rtype: dict
"""
return self._post(
'card/paygiftcard/getbyid',
... |
批量查询支付后投放卡券的规则 详情请参见 https:// mp. weixin. qq. com/ wiki?id = mp1466494654_K9rNz | def batch_get_pay_giftcard(self, effective=True, offset=0, count=10):
"""
批量查询支付后投放卡券的规则
详情请参见
https://mp.weixin.qq.com/wiki?id=mp1466494654_K9rNz
:param effective: 是否仅查询生效的规则
:type effective: bool
:param offset: 起始偏移量
:type offset: int
:param co... |
更新电影票 | def update_movie_ticket(self, code, ticket_class, show_time, duration,
screening_room, seat_number, card_id=None):
"""
更新电影票
"""
ticket = {
'code': code,
'ticket_class': ticket_class,
'show_time': show_time,
'dur... |
飞机票接口 | def checkin_boardingpass(self, code, passenger_name, seat_class,
etkt_bnr, seat='', gate='', boarding_time=None,
is_cancel=False, qrcode_data=None, card_id=None):
"""
飞机票接口
"""
data = {
'code': code,
'passe... |
更新红包余额 | def update_luckymoney_balance(self, code, balance, card_id=None):
"""
更新红包余额
"""
card_data = {
'code': code,
'balance': balance
}
if card_id:
card_data['card_id'] = card_id
return self._post(
'card/luckymoney/updateu... |
获取卡券跳转外链 | def get_redirect_url(self, url, encrypt_code, card_id):
"""
获取卡券跳转外链
"""
from wechatpy.utils import WeChatSigner
code = self.decrypt_code(encrypt_code)
signer = WeChatSigner()
signer.add_data(self.secret)
signer.add_data(code)
signer.add_data(car... |
导入code | def deposit_code(self, card_id, codes):
"""
导入code
"""
card_data = {
'card_id': card_id,
'code': codes
}
return self._post(
'card/code/deposit',
data=card_data
) |
核查code | def check_code(self, card_id, codes):
"""
核查code
"""
card_data = {
'card_id': card_id,
'code': codes
}
return self._post(
'card/code/checkcode',
data=card_data
) |
修改库存 | def modify_stock(self, card_id, n):
"""
修改库存
"""
if n == 0:
return
card_data = {
'card_id': card_id,
}
if n > 0:
card_data['increase_stock_value'] = n
elif n < 0:
card_data['reduce_stock_value'] = -n
... |
获取开卡插件 Url 内含调用开卡插件所需的参数 详情请参考 https:// mp. weixin. qq. com/ wiki?id = mp1499332673_Unm7V | def get_activate_url(self, card_id, outer_str=None):
"""
获取开卡插件 Url, 内含调用开卡插件所需的参数
详情请参考
https://mp.weixin.qq.com/wiki?id=mp1499332673_Unm7V
:param card_id: 会员卡的card_id
:param outer_str: 渠道值,用于统计本次领取的渠道参数
:return: 内含调用开卡插件所需的参数的 Url
"""
return sel... |
获取用户开卡时提交的信息 详情请参考 https:// mp. weixin. qq. com/ wiki?id = mp1499332673_Unm7V | def get_activate_info(self, activate_ticket):
"""
获取用户开卡时提交的信息
详情请参考
https://mp.weixin.qq.com/wiki?id=mp1499332673_Unm7V
:param activate_ticket: 跳转型开卡组件开卡后回调中的激活票据,可以用来获取用户开卡资料
:return: 用户开卡时填写的字段值
"""
return self._post(
'card/membercard/activ... |
设置开卡字段接口 详情请参考 https:// mp. weixin. qq. com/ wiki?t = resource/ res_main&id = mp1451025283 6 激活会员卡 - > 6. 2 一键激活 - > 步骤二:设置开卡字段接口 | def set_activate_user_form(self, card_id, **kwargs):
"""
设置开卡字段接口
详情请参考
https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025283
"6 激活会员卡" -> "6.2 一键激活" -> "步骤二:设置开卡字段接口"
参数示例:
{
"card_id": "pbLatjnrwUUdZI641gKdTMJzHGfc",
"service... |
获取 JSAPI 签名 | def get_jsapi_signature(self, prepay_id, timestamp=None, nonce_str=None):
"""
获取 JSAPI 签名
:param prepay_id: 统一下单接口返回的 prepay_id 参数值
:param timestamp: 可选,时间戳,默认为当前时间戳
:param nonce_str: 可选,随机字符串,默认自动生成
:return: 签名
"""
data = {
'appId': self.sub_... |
获取 JSAPI 参数 | def get_jsapi_params(self, prepay_id, timestamp=None, nonce_str=None, jssdk=False):
"""
获取 JSAPI 参数
:param prepay_id: 统一下单接口返回的 prepay_id 参数值
:param timestamp: 可选,时间戳,默认为当前时间戳
:param nonce_str: 可选,随机字符串,默认自动生成
:param jssdk: 前端调用方式,默认使用 WeixinJSBridge
... |
获取 access token 详情请参考 http:// mp. weixin. qq. com/ wiki/ index. php?title = 通用接口文档 | def fetch_access_token(self):
"""
获取 access token
详情请参考 http://mp.weixin.qq.com/wiki/index.php?title=通用接口文档
:return: 返回的 JSON 数据包
"""
return self._fetch_access_token(
url='https://api.weixin.qq.com/cgi-bin/token',
params={
'grant_t... |
获取 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 | def fetch_access_token(self):
"""
获取 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
这是内部刷新机制。请不要完全依赖!
因为有可能在缓存期间没有对此公众号的操作,造成refresh_token失效。
:return: 返回的 JSON... |
更新部门 | def update(self, id, name=None, parent_id=None, order=None):
"""
更新部门
https://work.weixin.qq.com/api/doc#90000/90135/90206
:param id: 部门 id
:param name: 部门名称。长度限制为1~32个字符,字符不能包括\\:?”<>|
:param parent_id: 父亲部门id
:param order: 在父部门中的次序值。order值大的排序靠前。有效的值范围是[0, 2^3... |
获取指定部门列表 | def get(self, id=None):
"""
获取指定部门列表
https://work.weixin.qq.com/api/doc#90000/90135/90208
权限说明:
只能拉取token对应的应用的权限范围内的部门列表
:param id: 部门id。获取指定部门及其下的子部门。 如果不填,默认获取全量组织架构
:return: 部门列表
"""
if id is None:
res = self._get('department/lis... |
获取部门成员:https:// work. weixin. qq. com/ api/ doc#90000/ 90135/ 90200 获取部门成员详情:https:// work. weixin. qq. com/ api/ doc#90000/ 90135/ 90201 | def get_users(self, id, status=0, fetch_child=0, simple=True):
"""
获取部门成员:https://work.weixin.qq.com/api/doc#90000/90135/90200
获取部门成员详情:https://work.weixin.qq.com/api/doc#90000/90135/90201
:param id: 部门 id
:param status: 0 获取全部员工,1 获取已关注成员列表,
2 获取禁用成员列表,4 ... |
增量更新成员 | def sync_user(self, url, token, encoding_aes_key, media_id, to_invite=True):
"""
增量更新成员
https://work.weixin.qq.com/api/doc#90000/90135/90980
:param url: 企业应用接收企业微信推送请求的访问协议和地址,支持http或https协议
:param token: 用于生成签名
:param encoding_aes_key: 用于消息体的加密,是AES密钥的Base64编码
... |
全量覆盖部门 | def replace_party(self, url, token, encoding_aes_key, media_id):
"""
全量覆盖部门
https://work.weixin.qq.com/api/doc#90000/90135/90982
:param url: 企业应用接收企业微信推送请求的访问协议和地址,支持http或https协议
:param token: 用于生成签名
:param encoding_aes_key: 用于消息体的加密,是AES密钥的Base64编码
:param media... |
邀请成员 | def invite(self, user=None, party=None, tag=None):
"""
邀请成员
https://work.weixin.qq.com/api/doc#90000/90135/90975
企业可通过接口批量邀请成员使用企业微信,邀请后将通过短信或邮件下发通知。
:param user: 成员ID列表, 最多支持1000个。
:param party: 成员ID列表, 最多支持100个。
:param tag: 成员ID列表, 最多支持100个。
:return: ... |
邀请成员关注 ( deprecated ) https:// qydev. weixin. qq. com/ wiki/ index. php?title = 异步任务接口 | def invite_user(self, url, token, encoding_aes_key, user_ids=None,
party_ids=None, tag_ids=None, invite_tips=None):
"""
邀请成员关注(deprecated)
https://qydev.weixin.qq.com/wiki/index.php?title=异步任务接口
:param url: 企业应用接收企业微信推送请求的访问协议和地址,支持http或https协议
:param token: ... |
创建分组 | def create(self, name):
"""
创建分组
详情请参考
http://mp.weixin.qq.com/wiki/0/56d992c605a97245eb7e617854b169fc.html
:param name: 分组名字(30个字符以内)
:return: 返回的 JSON 数据包
使用示例::
from wechatpy import WeChatClient
client = WeChatClient('appid', 'secre... |
查询所有分组或查询用户所在分组 ID | def get(self, user_id=None):
"""
查询所有分组或查询用户所在分组 ID
详情请参考
http://mp.weixin.qq.com/wiki/0/56d992c605a97245eb7e617854b169fc.html
:param user_id: 用户 ID,提供时查询该用户所在分组,否则查询所有分组
:return: 所有分组列表或用户所在分组 ID
使用示例::
from wechatpy import WeChatClient
... |
修改分组名 | def update(self, group_id, name):
"""
修改分组名
详情请参考
http://mp.weixin.qq.com/wiki/0/56d992c605a97245eb7e617854b169fc.html
:param group_id: 分组id,由微信分配
:param name: 分组名字(30个字符以内)
:return: 返回的 JSON 数据包
使用示例::
from wechatpy import WeChatClient
... |
移动用户分组 | def move_user(self, user_id, group_id):
"""
移动用户分组
详情请参考
http://mp.weixin.qq.com/wiki/0/56d992c605a97245eb7e617854b169fc.html
:param user_id: 用户 ID, 可以是单个或者列表,为列表时为批量移动用户分组
:param group_id: 分组 ID
:return: 返回的 JSON 数据包
使用示例::
from wechatpy i... |
Check WeChat callback signature raises InvalidSignatureException if check failed. | def check_signature(token, signature, timestamp, nonce):
"""Check WeChat callback signature, raises InvalidSignatureException
if check failed.
:param token: WeChat callback token
:param signature: WeChat callback signature sent by WeChat server
:param timestamp: WeChat callback timestamp sent by We... |
Convert value to unicode default encoding is utf - 8 | def to_text(value, encoding='utf-8'):
"""Convert value to unicode, default encoding is utf-8
:param value: Value to be converted
:param encoding: Desired encoding
"""
if not value:
return ''
if isinstance(value, six.text_type):
return value
if isinstance(value, six.binary_ty... |
Convert value to binary string default encoding is utf - 8 | def to_binary(value, encoding='utf-8'):
"""Convert value to binary string, default encoding is utf-8
:param value: Value to be converted
:param encoding: Desired encoding
"""
if not value:
return b''
if isinstance(value, six.binary_type):
return value
if isinstance(value, si... |
Try to get timezone using pytz or python - dateutil | def timezone(zone):
"""Try to get timezone using pytz or python-dateutil
:param zone: timezone str
:return: timezone tzinfo or None
"""
try:
import pytz
return pytz.timezone(zone)
except ImportError:
pass
try:
from dateutil.tz import gettz
return gett... |
Get Querystring information from uri. | def get_querystring(uri):
"""Get Querystring information from uri.
:param uri: uri
:return: querystring info or {}
"""
parts = urlparse.urlsplit(uri)
return urlparse.parse_qs(parts.query) |
Add data to signer | def add_data(self, *args):
"""Add data to signer"""
for data in args:
self._data.append(to_binary(data)) |
Get data signature | def signature(self):
"""Get data signature"""
self._data.sort()
str_to_sign = self._delimiter.join(self._data)
return hashlib.sha1(str_to_sign).hexdigest() |
获取门店列表 | def list_shops(self, page_index=1, page_size=20):
"""
获取门店列表
详情请参考
http://mp.weixin.qq.com/wiki/15/bcfb5d4578ea818b89913472cf2bbf8f.html
:param page_index: 可选,分页下标,默认从1开始
:param page_size: 可选,每页的个数,默认20个,最大20个
:return: 返回的 JSON 数据包
"""
res = self... |
查询门店的WiFi信息 http:// mp. weixin. qq. com/ wiki/ 15/ bcfb5d4578ea818b89913472cf2bbf8f. html | def get_shop(self, shop_id=0):
"""
查询门店的WiFi信息
http://mp.weixin.qq.com/wiki/15/bcfb5d4578ea818b89913472cf2bbf8f.html
:param shop_id: 门店 ID
:return: 返回的 JSON 数据包
"""
res = self._post(
'shop/get',
data={
'shop_id': shop_id,
... |
添加设备 | def add_device(self, shop_id, ssid, password, bssid):
"""
添加设备
详情请参考
http://mp.weixin.qq.com/wiki/10/6232005bdc497f7cf8e19d4e843c70d2.html
:param shop_id: 门店 ID
:param ssid: 无线网络设备的ssid。非认证公众号添加的ssid必需是“WX”开头(“WX”为大写字母),
认证公众号和第三方平台无此限制;所有ssid均不能包含中... |
查询设备 | def list_devices(self, shop_id=None, page_index=1, page_size=20):
"""
查询设备
详情请参考
http://mp.weixin.qq.com/wiki/10/6232005bdc497f7cf8e19d4e843c70d2.html
:param shop_id: 可选,门店 ID
:param page_index: 可选,分页下标,默认从1开始
:param page_size: 可选,每页的个数,默认20个,最大20个
:retu... |
获取物料二维码图片网址 | def get_qrcode_url(self, shop_id, img_id):
"""
获取物料二维码图片网址
详情请参考
http://mp.weixin.qq.com/wiki/7/fcd0378ef00617fc276be2b3baa80973.html
:param shop_id: 门店 ID
:param img_id: 物料样式编号:0-二维码,可用于自由设计宣传材料;
1-桌贴(二维码),100mm×100mm(宽×高),可直接张贴
:return: ... |
设置商家主页 | def set_homepage(self, shop_id, template_id, url=None):
"""
设置商家主页
详情请参考
http://mp.weixin.qq.com/wiki/6/2732f3cf83947e0e4971aa8797ee9d6a.html
:param shop_id: 门店 ID
:param template_id: 模板ID,0-默认模板,1-自定义url
:param url: 自定义链接,当template_id为1时必填
:return: 返回的 ... |
查询商家主页 | def get_homepage(self, shop_id):
"""
查询商家主页
详情请参考
http://mp.weixin.qq.com/wiki/6/2732f3cf83947e0e4971aa8797ee9d6a.html
:param shop_id: 门店 ID
:return: 返回的 JSON 数据包
"""
res = self._post(
'homepage/get',
data={'shop_id': shop_id},
... |
Wi - Fi数据统计 | def list_statistics(self, begin_date, end_date, shop_id=-1):
"""
Wi-Fi数据统计
详情请参考
http://mp.weixin.qq.com/wiki/8/dfa2b756b66fca5d9b1211bc18812698.html
:param begin_date: 起始日期时间,最长时间跨度为30天
:param end_date: 结束日期时间戳,最长时间跨度为30天
:param shop_id: 可选,门店 ID,按门店ID搜索,-1为总统计... |
构造网页授权链接 详情请参考 https:// work. weixin. qq. com/ api/ doc#90000/ 90135/ 91022 | def authorize_url(self, redirect_uri, state=None):
"""
构造网页授权链接
详情请参考
https://work.weixin.qq.com/api/doc#90000/90135/91022
:param redirect_uri: 授权后重定向的回调链接地址
:param state: 重定向后会带上 state 参数
:return: 返回的 JSON 数据包
"""
redirect_uri = six.moves.urllib.... |
刷卡支付接口: param device_info: 可选,终端设备号 ( 商户自定义,如门店编号 ): param body: 商品描述: param detail: 可选,商品详情: param attach: 可选,附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据: param client_ip: 可选,APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP: param out_trade_no: 可选,商户订单号,默认自动生成: param total_fee: 总金额,单位分: param fee_type: 可选,符合ISO 4217标准的三位字母代码,默认人... | def create(self, body, total_fee, auth_code, client_ip=None, out_trade_no=None, detail=None, attach=None,
fee_type='CNY', goods_tag=None, device_info=None, limit_pay=None):
"""
刷卡支付接口
:param device_info: 可选,终端设备号(商户自定义,如门店编号)
:param body: 商品描述
:param detail: 可选,商品详... |
创建标签 | def create(self, name):
"""
创建标签
:param name: 标签名(30个字符以内)
:return: 返回的 JSON 数据包
"""
name = to_text(name)
return self._post(
'tags/create',
data={'tag': {'name': name}},
result_processor=lambda x: x['tag']
) |
编辑标签 | def update(self, tag_id, name):
"""
编辑标签
:param tag_id: 标签id,由微信分配
:param name: 标签名字(30个字符以内)
:return: 返回的 JSON 数据包
"""
name = to_text(name)
return self._post(
'tags/update',
data={
'tag': {
'id... |
批量为用户打标签 | def tag_user(self, tag_id, user_id):
"""
批量为用户打标签
:param tag_id: 标签 ID
:param user_id: 用户 ID, 可以是单个或者列表
:return: 返回的 JSON 数据包
"""
data = {'tagid': tag_id}
if isinstance(user_id, (tuple, list)):
data['openid_list'] = user_id
else:
... |
获取用户身上的标签列表 | def get_user_tag(self, user_id):
"""
获取用户身上的标签列表
:param user_id: 用户 ID, 可以是单个或者列表
:return: 返回的 JSON 数据包
"""
return self._post(
'tags/getidlist',
data={
'openid': user_id
},
result_processor=lambda x: x['tagi... |
获取标签下粉丝列表 | def get_tag_users(self, tag_id, first_user_id=None):
"""
获取标签下粉丝列表
:param tag_id: 标签 ID
:param first_user_id: 可选。第一个拉取的 OPENID,不填默认从头开始拉取
:return: 返回的 JSON 数据包
"""
data = {
'tagid': tag_id,
}
if first_user_id:
data['next_op... |
获取标签下粉丝openid列表 | def iter_tag_users(self, tag_id, first_user_id=None):
"""
获取标签下粉丝openid列表
:return: 返回一个迭代器,可以用for进行循环,得到openid
使用示例::
from wechatpy import WeChatClient
client = WeChatClient('appid', 'secret')
for openid in client.tag.iter_tag_users(0):
... |
获取公众号的黑名单列表 详情请参考 https:// mp. weixin. qq. com/ wiki?id = mp1471422259_pJMWA | def get_black_list(self, begin_openid=None):
"""
获取公众号的黑名单列表
详情请参考
https://mp.weixin.qq.com/wiki?id=mp1471422259_pJMWA
:param begin_openid: 起始的 OpenID,传空则默认从头开始拉取
:return: 返回的 JSON 数据包
:rtype: dict
"""
data = {}
if begin_openid:
... |
创建小程序码(接口A: 适用于需要的码数量较少的业务场景) 详情请参考 https:// mp. weixin. qq. com/ debug/ wxadoc/ dev/ api/ qrcode. html | def get_wxa_code(self,
path,
width=430,
auto_color=False,
line_color={"r": "0", "g": "0", "b": "0"},
is_hyaline=False):
"""
创建小程序码(接口A: 适用于需要的码数量较少的业务场景)
详情请参考
https://mp.weixin.qq.co... |
创建小程序码(接口B:适用于需要的码数量极多,或仅临时使用的业务场景) 详情请参考 https:// mp. weixin. qq. com/ debug/ wxadoc/ dev/ api/ qrcode. html | def get_wxa_code_unlimited(self,
scene,
width=430,
auto_color=False,
line_color={"r": "0", "g": "0", "b": "0"},
page=None,
is_hyaline=... |
发送模板消息 详情请参考 https:// mp. weixin. qq. com/ debug/ wxadoc/ dev/ api/ notice. html | def send_template_message(self, user_id, template_id, data, form_id, page=None, color=None, emphasis_keyword=None):
"""
发送模板消息
详情请参考
https://mp.weixin.qq.com/debug/wxadoc/dev/api/notice.html
"""
tpl_data = optionaldict(
touser=user_id,
template_id=... |
修改小程序服务器授权域名 详情请参考 https:// open. weixin. qq. com/ cgi - bin/ showdocument?action = dir_list&id = open1489138143_WPbOO | def modify_domain(self, action, request_domain=(), wsrequest_domain=(), upload_domain=(), download_domain=()):
"""
修改小程序服务器授权域名
详情请参考
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489138143_WPbOO
:param action: 增删改查的操作类型,仅支持 'add', 'delete', 'set', 'get... |
为授权的小程序账号上传小程序代码 详情请参考 https:// open. weixin. qq. com/ cgi - bin/ showdocument?action = dir_list&id = open1489140610_Uavc4 | def commit(self, template_id, ext_json, version, description):
"""
为授权的小程序账号上传小程序代码
详情请参考
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140610_Uavc4
:param template_id: 代码库中的代码模板 ID
:param ext_json: 第三方自定义的配置
:param version: 代码版本号,开发者... |
将第三方提交的代码包提交审核 详情请参考 https:// open. weixin. qq. com/ cgi - bin/ showdocument?action = dir_list&id = open1489140610_Uavc4 | def submit_audit(self, item_list):
"""
将第三方提交的代码包提交审核
详情请参考
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140610_Uavc4
:param item_list: 提交审核项的一个列表(至少填写1项,至多填写5项)
:type item_list: list[dict]
:return: 审核编号
:rtype: int
"... |
获取本账号内所有模板 详情请参考 https:// open. weixin. qq. com/ cgi - bin/ showdocument?action = dir_list&id = open1500465446_j4CgR | def list_templates(self, offset=0, count=20):
"""
获取本账号内所有模板
详情请参考
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1500465446_j4CgR
:param offset: 用于分页,表示起始量,最小值为0
:type offset: int
:param count: 用于分页,表示拉取数量,最大值为20
:type count: int
... |
组合模板,并将其添加至账号下的模板列表里 详情请参考 https:// open. weixin. qq. com/ cgi - bin/ showdocument?action = dir_list&id = open1500465446_j4CgR | def add_template(self, template_short_id, keyword_id_list):
"""
组合模板,并将其添加至账号下的模板列表里
详情请参考
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1500465446_j4CgR
:param template_short_id: 模板标题ID
:param keyword_id_list: 按照顺序排列的模板关键词列表,最多10个
:type ... |
创建开放平台账号,并绑定公众号/ 小程序 详情请参考 https:// open. weixin. qq. com/ cgi - bin/ showdocument?action = dir_list&id = open1498704199_1bcax | def create_open(self, appid):
"""
创建开放平台账号,并绑定公众号/小程序
详情请参考
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1498704199_1bcax
:param appid: 授权公众号或小程序的 appid
:return: 开放平台的 appid
"""
return self._post(
'cgi-bin/open/create... |
获取公众号/ 小程序所绑定的开放平台账号 详情请参考 https:// open. weixin. qq. com/ cgi - bin/ showdocument?action = dir_list&id = open1498704199_1bcax | def get_open(self, appid):
"""
获取公众号/小程序所绑定的开放平台账号
详情请参考
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1498704199_1bcax
:param appid: 授权公众号或小程序的 appid
:return: 开放平台的 appid
"""
return self._post(
'cgi-bin/open/get',
... |
登录凭证校验。通过 wx. login () 接口获得临时登录凭证 code 后传到开发者服务器调用此接口完成登录流程。更多使用方法详见 小程序登录 详情请参考 https:// developers. weixin. qq. com/ miniprogram/ dev/ api/ code2Session. html | def code_to_session(self, js_code):
"""
登录凭证校验。通过 wx.login() 接口获得临时登录凭证 code 后传到开发者服务器调用此接口完成登录流程。更多使用方法详见 小程序登录
详情请参考
https://developers.weixin.qq.com/miniprogram/dev/api/code2Session.html
:param js_code:
:return:
"""
return self._get(
'sns/j... |
发送语义理解请求 详情请参考 http:// mp. weixin. qq. com/ wiki/ 0/ 0ce78b3c9524811fee34aba3e33f3448. html | def search(self,
query,
category,
uid=None,
latitude=None,
longitude=None,
city=None,
region=None):
"""
发送语义理解请求
详情请参考
http://mp.weixin.qq.com/wiki/0/0ce78b3c9524811fee34aba3e33f3448.... |
设置应用 https:// work. weixin. qq. com/ api/ doc#90000/ 90135/ 90228 | def set(self,
agent_id,
name=None,
description=None,
redirect_domain=None,
logo_media_id=None,
report_location_flag=0,
is_report_user=True,
is_report_enter=True):
"""
设置应用
https://work.weixin.qq.com/a... |
获取 JSAPI 签名 | def get_jsapi_signature(self, noncestr, ticket, timestamp, url):
"""
获取 JSAPI 签名
https://work.weixin.qq.com/api/doc#90001/90144/90539/签名算法/
:param noncestr: nonce string
:param ticket: JS-SDK ticket
:param timestamp: 时间戳
:param url: URL
:return: 签名
... |
获取微信 JS - SDK ticket | def get_jsapi_ticket(self):
"""
获取微信 JS-SDK ticket
该方法会通过 session 对象自动缓存管理 ticket
:return: ticket
"""
ticket_key = '{}_jsapi_ticket'.format(self._client.corp_id)
expires_at_key = '{}_jsapi_ticket_expires_at'.format(self._client.corp_id)
ticket = self.ses... |
获取应用的jsapi_ticket | def get_agent_jsapi_ticket(self):
"""
获取应用的jsapi_ticket
该方法会通过 session 对象自动缓存管理 ticket
:return: ticket
"""
ticket_key = '{}_agent_jsapi_ticket'.format(self._client.corp_id)
expires_at_key = '{}_agent_jsapi_ticket_expires_at'.format(self._client.corp_id)
... |
申请退款 | def apply(self, total_fee, refund_fee, out_refund_no, transaction_id=None,
out_trade_no=None, fee_type='CNY', op_user_id=None,
device_info=None, refund_account='REFUND_SOURCE_UNSETTLED_FUNDS',
notify_url=None):
"""
申请退款
:param total_fee: 订单总金额,单位为分
... |
查询退款 | def query(self, refund_id=None, out_refund_no=None, transaction_id=None,
out_trade_no=None, device_info=None):
"""
查询退款
:param refund_id: 微信退款单号
:param out_refund_no: 商户退款单号
:param transaction_id: 微信订单号
:param out_trade_no: 商户系统内部的订单号
:param device_... |
修改商品 | def update(self, product_id, product_data):
"""修改商品"""
product_data['product_id'] = product_id
return self._post(
'merchant/update',
data=product_data
) |
增加库存 | def add_stock(self, product_id, sku_info, quantity):
"""
增加库存
:param product_id: 商品ID
:param sku_info: sku信息,格式"id1:vid1;id2:vid2",如商品为统一规格,则此处赋值为空字符串即可
:param quantity: 增加的库存数量
:return: 返回的 JSON 数据包
"""
return self._post(
'merchant/stock/add'... |
减少库存 | def reduce_stock(self, product_id, sku_info, quantity):
"""
减少库存
:param product_id: 商品ID
:param sku_info: sku信息,格式"id1:vid1;id2:vid2",如商品为统一规格,则此处赋值为空字符串即可
:param quantity: 减少的库存数量
:return: 返回的 JSON 数据包
"""
return self._post(
'merchant/stock/r... |
增加邮费模板 | def update_express(self, template_id, delivery_template):
"""
增加邮费模板
:param template_id: 邮费模板ID
:param delivery_template: 邮费模板信息(字段说明详见增加邮费模板)
:return: 返回的 JSON 数据包
"""
delivery_template['template_id'] = template_id
return self._post(
'merchan... |
修改分组属性 | def update_group_property(self, group_id, group_properties):
"""
修改分组属性
:param group_id: 商品分组ID
:param group_properties: 商品分组属性
:return: 返回的 JSON 数据包
"""
group_properties['group_id'] = group_id
return self._post(
'merchant/group/propertymod',
... |
修改分组商品 | def update_group_product(self, group_id, product_data):
"""
修改分组商品
:param group_id: 商品分组ID
:param product_data: 分组商品信息
:return: 返回的 JSON 数据包
"""
product_data['group_id'] = group_id
return self._post(
'merchant/group/productmod',
da... |
修改货架 | def update_shelf(self, shelf_id, shelf_data):
"""
修改货架
:param shelf_id: 货架ID
:param shelf_data: 货架详情
:return: 返回的 JSON 数据包
"""
shelf_data['shelf_id'] = shelf_id
return self._post(
'merchant/shelf/mod',
data=shelf_data
) |
根据订单状态/ 创建时间获取订单详情 | def query_order(self, status=None, begintime=None, endtime=None):
"""
根据订单状态/创建时间获取订单详情
:param status: 订单状态(不带该字段-全部状态, 2-待发货, 3-已发货, 5-已完成, 8-维权中, )
:param begintime: 订单创建时间起始时间(不带该字段则不按照时间做筛选)
:param endtime: 订单创建时间终止时间(不带该字段则不按照时间做筛选)
:return: 返回的 JSON 数据包
"""... |
修改货架 | def set_delivery(self, order_id, delivery_data):
"""
修改货架
:param order_id: 订单ID
:param delivery_data: 商品物流信息
:return: 返回的 JSON 数据包
"""
delivery_data['order_id'] = order_id
return self._post(
'merchant/shelf/setdeliverymod',
data=de... |
长链接转短链接 | def short_url(self, long_url):
"""
长链接转短链接
:param long_url: 长链接
:return: 返回的结果数据
"""
data = {
'appid': self.appid,
'long_url': long_url,
}
return self._post('tools/shorturl', data=data) |
下载对账单 | def download_bill(self, bill_date, bill_type='ALL', device_info=None):
"""
下载对账单
:param bill_date: 下载对账单的日期
:param bill_type: 账单类型,ALL,返回当日所有订单信息,默认值
SUCCESS,返回当日成功支付的订单,
REFUND,返回当日退款订单,
REVOKED,已撤销的订单
... |
下载资金账单 https:// pay. weixin. qq. com/ wiki/ doc/ api/ jsapi. php?chapter = 9_18&index = 7 | def download_fundflow(self, bill_date, account_type='Basic',
tar_type=None):
"""
下载资金账单
https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_18&index=7
:param bill_date: 下载对账单的日期
:param account_type: 账单的资金来源账户
Basic 基... |
授权码查询 openid 接口 | def auto_code_to_openid(self, auth_code):
"""
授权码查询 openid 接口
:param auth_code: 扫码支付授权码,设备读取用户微信中的条码或者二维码信息
:return: 返回的结果数据
"""
data = {
'appid': self.appid,
'auth_code': auth_code,
}
return self._post('tools/authcodetoopenid', da... |
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 消息 | 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... |
发送文本消息 | 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 数据... |
发送图片消息 | 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:... |
发送语音消息 | 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... |
发送视频消息 | 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。 可... |
发送音乐消息 | 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:... |
发送图文消息 | 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:... |
发送卡券消息 | 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... |
发送小程序卡片(要求小程序与公众号已关联) | 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... |
群发文本消息 | 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: 值为整型数字时为按分组群发,... |
群发视频消息 | 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... |
群发图文消息 | 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: 值为整型... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.