0.2.0 • Published 11 years ago
wechat-koa v0.2.0
wechat-koa
基于生成器开发的微信公众平台组件,用于koa框架
Installation
$ npm install wechat-koa
Example
初始化对象
var WechatKoa = require('wechat-koa');
var wechatKoa = new WechatKoa({
store: {type: 'mongo',url:'mongodb://127.0.0.1:27017/db'},
appId: 'your appId',
appSecret: 'your appSecret',
token: 'your appToken'
});
微信验证方法
function* signature() {
if (this.req.url) {
var echostr = wechatKoa.checkSignature(this.req.url)
if (echostr) {
this.body = echostr;
} else {
this.status = 500;
this.body = "Bad Token!";
}
}
}
消息解析回复
function* onWechatMsg(){
var msg = yield wechatKoa.parse(postQuery);
var responesMsg = {
"toUserName":msg.FromUserName,
"fromUserName":msg.ToUserName,
"createTime":new Date().toTimeString(),
"msgType":"text",
"content":"reponse text"
};
this.type = 'application/xml'
this.body = wechatKoa.build(responesMsg);
}
License
MIT
0.2.0
11 years ago
0.1.9
11 years ago
0.1.8
11 years ago
0.1.7
11 years ago
0.1.6
11 years ago
0.1.5
11 years ago
0.1.4
11 years ago
0.1.3
11 years ago
0.1.2
11 years ago
0.1.1
11 years ago
0.1.0
11 years ago
0.0.10
11 years ago
0.0.9
11 years ago
0.0.8
11 years ago
0.0.7
11 years ago
0.0.6
11 years ago
0.0.5
11 years ago
0.0.4
11 years ago
0.0.3
11 years ago
0.0.2
11 years ago
0.0.1
11 years ago