https://github.com/unicreators/wx-extend-api
wechat/weixin extend api.
https://github.com/unicreators/wx-extend-api
api extend wechat weixin wx
Last synced: 7 months ago
JSON representation
wechat/weixin extend api.
- Host: GitHub
- URL: https://github.com/unicreators/wx-extend-api
- Owner: unicreators
- License: mit
- Created: 2017-09-12T03:59:48.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-12T08:38:58.000Z (about 8 years ago)
- Last Synced: 2025-03-08T05:18:49.205Z (7 months ago)
- Topics: api, extend, wechat, weixin, wx
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## wx-extend-api
wechat/weixin extend api.
## Install
```sh
$ npm install wx-extend-api
```## Usage
### STEP 1: Custom extend
```js
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
```js
let api = new WeixinApi('appId', 'appSecret');
// register
api.extend('message', MessageExtend);```
### STEP 3: Use
```js
api.message.send('openId', 'content')
.then(function (result) {
// ..
}).catch(function (err) {
// ..
});
// or
// await api.message.send('openId', 'content');```
### License
[MIT](LICENSE)