Skip to content

Commit

Permalink
更新 WeChatQRCode 注释 (#701)
Browse files Browse the repository at this point in the history
Co-authored-by: yaoqiankun <yaoqiankun@datarc.cn>
  • Loading branch information
yqkcn and yaoqiankun committed Mar 15, 2022
1 parent 31edc6b commit 1688490
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions wechatpy/client/api/qrcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,52 @@ class WeChatQRCode(BaseWeChatAPI):
def create(self, qrcode_data):
"""
创建二维码
详情请参考
https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1443433542
https://developers.weixin.qq.com/doc/offiaccount/Account_Management/Generating_a_Parametric_QR_Code.html
:param data: 你要发送的参数 dict
:param qrcode_data: 你要发送的参数 dict
:return: 返回的 JSON 数据包
使用示例::
from wechatpy import WeChatClient
client = WeChatClient('appid', 'secret')
res = client.qrcode.create({
'expire_seconds': 1800,
'action_name': 'QR_SCENE',
'action_info': {
'scene': {'scene_id': 123},
}
})
# 创建永久的二维码, 参数使用字符串而不是数字id
res = client.qrcode.create({
'action_name': 'QR_LIMIT_STR_SCENE',
'action_info': {
'scene': {'scene_str': "scan_qrcode_from_scene"},
}
})
>>> from wechatpy import WeChatClient
>>>
>>> client = WeChatClient('appid', 'secret')
>>> res = client.qrcode.create({
>>> 'expire_seconds': 1800,
>>> 'action_name': 'QR_SCENE',
>>> 'action_info': {
>>> 'scene': {'scene_id': 123},
>>> }
>>> })
>>> # 创建永久的二维码, 参数使用字符串而不是数字id
>>> res = client.qrcode.create({
>>> 'action_name': 'QR_LIMIT_STR_SCENE',
>>> 'action_info': {
>>> 'scene': {'scene_str': "scan_qrcode_from_scene"},
>>> }
>>> })
"""
return self._post("qrcode/create", data=qrcode_data)

def show(self, ticket):
"""
通过ticket换取二维码
详情请参考
https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1443433542
https://developers.weixin.qq.com/doc/offiaccount/Account_Management/Generating_a_Parametric_QR_Code.html
:param ticket: 二维码 ticket 。可以通过 :func:`create` 获取到
:return: 返回的 Request 对象
使用示例::
from wechatpy import WeChatClient
client = WeChatClient('appid', 'secret')
res = client.qrcode.show('ticket data')
>>> from wechatpy import WeChatClient
>>>
>>> client = WeChatClient('appid', 'secret')
>>> res = client.qrcode.show('ticket data')
"""
if isinstance(ticket, dict):
Expand All @@ -65,18 +67,19 @@ def show(self, ticket):
def get_url(cls, ticket):
"""
通过ticket换取二维码地址
详情请参考
https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1443433542
https://developers.weixin.qq.com/doc/offiaccount/Account_Management/Generating_a_Parametric_QR_Code.html
:param ticket: 二维码 ticket 。可以通过 :func:`create` 获取到
:return: 返回的二维码地址
使用示例::
from wechatpy import WeChatClient
client = WeChatClient('appid', 'secret')
url = client.qrcode.get_url('ticket data')
>>> from wechatpy import WeChatClient
>>>
>>> client = WeChatClient('appid', 'secret')
>>> url = client.qrcode.get_url('ticket data')
"""
if isinstance(ticket, dict):
Expand Down

0 comments on commit 1688490

Please sign in to comment.