- “获取微信callback IP地址” API获取的IP地址不全,无法用于配制后台服务器防火墙
根据https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_the_WeChat_server_IP_address.html 通过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
2022-12-06 - 怎样获取微信小程序调用 后台业务服务器使用的IP列表?后台服务器要设置IP白名单
根据 获取微信服务器 IP 地址这里的指引https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_the_WeChat_server_IP_address.html 获取微信callback IP地址、获取微信 API 接口 IP地址:{"ip_list":["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_list":["101.89.47.18","101.91.34.103","101.91.37.13","109.244.129.223","109.244.145.152","109.244.184.250","112.53.42.235","112.60.20.154","112.65.193.153","112.90.80.215","116.128.170.42","116.128.184.169","117.144.228.18","117.144.228.62","119.147.6.203","119.147.6.237","120.232.65.161","157.148.36.94","157.255.218.109","175.27.18.18","175.27.5.221","183.2.143.222","203.205.239.82","203.205.239.94","221.181.99.40","81.69.216.43"]} 配置到服务器白名单上,结果发现小程序访问后台不通。取消服务器白名单,发现实际收到的小程序侧地址是220.152.145.208,根本不在上述地址中。 请问究竟怎样获取到正确的小程序访问业务服务器所使用的IP列表? 还是说这个指引以前能用,现在不行了?
2022-12-03