通过http请求方式: GET https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=ACCESS_TOKEN
获取微信服务器小程序callback地址用于后台服务器防火墙配置后,发现小程序访问服务器不通。查看发现,从api查询回的IP列表是:
['106.55.206.146', '106.55.206.211', '106.55.207.148', '106.55.207.31', '118.126.124.186', '118.126.124.246', '119.29.180.49', '119.29.9.101', '124.223.151.119', '129.226.105.242', '162.62.80.57', '162.62.80.8', '162.62.81.123', '175.24.211.142', '175.24.211.157', '175.24.211.198', '175.24.211.31', '175.24.211.4', '175.24.212.10', '175.24.212.185', '175.24.212.195', '175.24.213.149', '175.24.214.150', '175.24.214.222', '175.27.64.215', '175.27.65.216', '42.192.0.152', '42.192.0.224', '42.192.6.57', '43.132.112.30', '43.132.141.238', '43.137.147.169', '43.143.52.12', '43.143.59.119', '81.69.101.193', '81.69.101.225', '81.69.101.233', '81.69.101.237', '81.69.103.129', '81.69.103.147', '81.69.103.163', '81.69.103.205', '81.69.103.236', '81.69.103.238', '81.69.103.37', '81.69.103.74', '81.71.140.59', '81.71.19.101']
而后台服务器实际收到的请求IP是117.136.33.145,该地址并不在api查询回的ip列表中。请确认,通过该api是否能查回完整的callbackip?是否需要用其它方式来获取完整IP列表?
def get_app_callbackips(appid, appsecret) :
token = get_app_token(appid, appsecret)
url = 'https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token='+token
req = request.Request(url)
rsp = request.urlopen(req)
result = rsp.read().decode()
result_obj = json.loads(result)
iplist = result_obj['ip_list']
return iplist
老师,有解决方案吗?我也遇到这个问题