Skip to content

Commit

Permalink
更新 WeChatMisc (#703)
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 16, 2022
1 parent ad43416 commit 152fdb9
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions wechatpy/client/api/misc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from operator import itemgetter

from wechatpy.client.api.base import BaseWeChatAPI

Expand All @@ -7,18 +8,22 @@ class WeChatMisc(BaseWeChatAPI):
def short_url(self, long_url):
"""
将一条长链接转成短链接
详情请参考
http://mp.weixin.qq.com/wiki/10/165c9b15eddcfbd8699ac12b0bd89ae6.html
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=
:param long_url: 长链接地址
:return: 返回的 JSON 数据包
使用示例::
from wechatpy import WeChatClient
client = WeChatClient('appid', 'secret')
res = client.misc.short_url('http://www.qq.com')
>>> from wechatpy import WeChatClient
>>>
>>> client = WeChatClient('appid', 'secret')
>>> res = client.misc.short_url('http://www.qq.com')
"""
return self._post("shorturl", data={"action": "long2short", "long_url": long_url})
Expand All @@ -27,17 +32,20 @@ def get_wechat_ips(self):
"""
获取微信服务器 IP 地址列表
详情请参考:
https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_the_WeChat_server_IP_address.html
:return: IP 地址列表
使用示例::
from wechatpy import WeChatClient
client = WeChatClient('appid', 'secret')
ips = client.misc.get_wechat_ips()
>>> from wechatpy import WeChatClient
>>>
>>> client = WeChatClient('appid', 'secret')
>>> ips = client.misc.get_wechat_ips()
"""
res = self._get("getcallbackip", result_processor=lambda x: x["ip_list"])
res = self._get("getcallbackip", result_processor=itemgetter("ip_list"))
return res

def check_network(self, action="all", operator="DEFAULT"):
Expand Down

0 comments on commit 152fdb9

Please sign in to comment.