1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- # -*- coding: utf-8 -*-
- from __future__ import absolute_import, unicode_literals
- from library.wechatpy.client.api.base import BaseWeChatAPI
- class WeChatMisc(BaseWeChatAPI):
- def short_url(self, long_url):
- """
- 将一条长链接转成短链接
- 详情请参考
- http://mp.weixin.qq.com/wiki/10/165c9b15eddcfbd8699ac12b0bd89ae6.html
- :param long_url: 长链接地址
- :return: 返回的 JSON 数据包
- 使用示例::
- 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
- }
- )
- def get_wechat_callback_ips(self):
- """
- 获取微信服务器回跳地址列表
- :return: 回跳地址列表
- 使用示例::
- from wechatpy import WeChatClient
- client = WeChatClient('appid', 'secret')
- ips = client.misc.get_wechat_callback_ips()
- """
- res = self._get(
- 'getcallbackip',
- result_processor=lambda x: x['ip_list']
- )
- return res
- def get_wechat_access_ips(self):
- """
- 获取微信服务器API接入入口地址列表
- :return: API接入入口地址列表
- 使用示例::
- from wechatpy import WeChatClient
- client = WeChatClient('appid', 'secret')
- ips = client.misc.get_wechat_access_ips()
- """
- res = self._get(
- 'get_api_domain_ip',
- result_processor=lambda x: x['ip_list']
- )
- return res
|