Wechat API
- Find the api entry from wechat wiki, for example: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840&token=&lang=zh_CN .
- Extract the api path, for example '/cgi-bin/user/get'.
- Call api method with api path and request parameters. For api(path, data), if request method is get, data should be querystring or not set, otherwise it should be post object.
const Wechat = require('wechat.api');
const wechat = new Wechat({
appid: 'xxx',
secret: 'xxx',
});
wechat.api('/cgi-bin/user/info', 'openid=xxx&lang=en').then(result => {
console.log(result);
}).catch(error => {
console.error('error', error);
});