wx-extend-api
v0.4.5
Published
weixin/wechat extend api.
Downloads
3
Readme
wx-extend-api
wechat/weixin extend api.
Install
$ npm install wx-extend-api
Usage
STEP 1: Custom extend
const { WeixinApi, ApiExtend } = require('wx-extend-api');
let MessageExtend = class MessageExtend extends ApiExtend {
async send(to, content) {
return await this.invoke(
'https://api.weixin.qq.com/cgi-bin/message/custom/send',
{
body: {
touser: to, msgtype: 'text',
text: { content }
}
}, 'POST');
}
};
STEP 2: Register extend
let api = new WeixinApi('appId', 'appSecret');
// register
api.extend('message', MessageExtend);
STEP 3: Use
api.message.send('openId', 'content')
.then(function (result) {
// ..
}).catch(function (err) {
// ..
});
// or
// await api.message.send('openId', 'content');