二维码接口#

class wechatpy.client.api.WeChatQRCode(client=None)[源代码]#
create(qrcode_data)[源代码]#

创建二维码

详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Account_Management/Generating_a_Parametric_QR_Code.html

参数

qrcode_data – 你要发送的参数 dict

返回

返回的 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"},
>>>        }
>>>    })
classmethod get_url(ticket)[源代码]#

通过ticket换取二维码地址

详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Account_Management/Generating_a_Parametric_QR_Code.html

参数

ticket – 二维码 ticket 。可以通过 create() 获取到

返回

返回的二维码地址

使用示例:

>>>    from wechatpy import WeChatClient
>>>
>>>    client = WeChatClient('appid', 'secret')
>>>    url = client.qrcode.get_url('ticket data')
show(ticket)[源代码]#

通过ticket换取二维码

详情请参考 https://developers.weixin.qq.com/doc/offiaccount/Account_Management/Generating_a_Parametric_QR_Code.html

参数

ticket – 二维码 ticket 。可以通过 create() 获取到

返回

返回的 Request 对象

使用示例:

>>>    from wechatpy import WeChatClient
>>>
>>>    client = WeChatClient('appid', 'secret')
>>>    res = client.qrcode.show('ticket data')