UNPKG

co-wechat-api

Version:

微信公共平台Node库API,ES6版本

24 lines (21 loc) 620 B
'use strict'; /** * 获取微信服务器IP地址 * 详情请见:<http://mp.weixin.qq.com/wiki/index.php?title=%E8%8E%B7%E5%8F%96%E5%BE%AE%E4%BF%A1%E6%9C%8D%E5%8A%A1%E5%99%A8IP%E5%9C%B0%E5%9D%80> * Examples: * ``` * api.getIp(); * ``` * Result: * ``` * { * "ip_list":["127.0.0.1","127.0.0.1"] * } * ``` */ exports.getIp = async function () { const { accessToken } = await this.ensureAccessToken(); // https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=ACCESS_TOKEN var url = this.prefix + 'getcallbackip?access_token=' + accessToken; return this.request(url, {dataType: 'json'}); };