工具类接口#

class wechatpy.client.api.WeChatMisc(client=None)[源代码]#
check_network(action='all', operator='DEFAULT')[源代码]#

网络检测

详情请参阅 https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Network_Detection.html

参数
  • action – 执行的检测动作,允许的值:dns(做域名解析)、ping(做ping检测)、all(dns和ping都做)

  • operator – 指定平台从某个运营商进行检测,允许的值:CHINANET(电信出口)、UNICOM(联通出口)、CAP(腾讯自建出口)、DEFAULT(根据ip来选择运营商)

返回

返回的 JSON 数据包

get_wechat_ips()[源代码]#

获取微信服务器 IP 地址列表

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

返回

IP 地址列表

使用示例:

>>>    from wechatpy import WeChatClient
>>>
>>>    client = WeChatClient('appid', 'secret')
>>>    ips = client.misc.get_wechat_ips()
short_url(long_url)[源代码]#

将一条长链接转成短链接

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

该接口即将废弃,详情见公告: https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncement&announce_id=11615366683l3hgk&version=63010043&lang=zh_CN&token=

参数

long_url – 长链接地址

返回

返回的 JSON 数据包

使用示例:

>>>    from wechatpy import WeChatClient
>>>
>>>    client = WeChatClient('appid', 'secret')
>>>    res = client.misc.short_url('http://www.qq.com')