node-wechat-api
v0.1.20
Published
### 开放平台
Downloads
16
Readme
微信 API 集合
开放平台
import express from 'express'
const app = express()
app.listen(3000)
const weChat = new WeChat(appId, appSecret, {
token : 'token', // 公众号消息校验Token
symmetricKey : 'symmetricKey' // 公众号消息加解密Key
})
app.post('/event', weChat.event()) // 需要与 授权事件接收URL 匹配
app.get('/auth', weChat.authenticate({
callbackURL: 'http://example.com/auth/callback' // 微信授权回跳链接
}))
app.get('/auth/callback', weChat.authenticate()) // 微信授权回跳链接
app.get('/app/:id/auth', weChat.appAuthenticate({
callbackURL: (req) => `http://example.com/app/${req.params.id}/callback`
}))
app.get('/app/:id/callback', weChat.appAuthenticate({}, (err, req, res, next, data) => {
res.json(data)
}))
app.get('/app/:id/js', weChat.js())
公众平台
import express from 'express'
const app = express()
app.listen(3000)
const weChatApp = new WeChatApp(appId, appSecret)
app.get('/auth', weChatApp.authenticate({
callbackURL: 'http://example.com/auth/callback'
}))
app.get('/auth/callback', weChatApp.authenticate({}, (err, req, res, next, data) => {
res.json(data)
}))
app.get('/js', weChatApp.js()) // 微信 jsAPI