0.0.12 • Published 8 years ago
kx-wechat v0.0.12
微信公众号API支持(WeChat Apis for node)
目录(Table of contents):
安装(Installation)
npm install kx-wechat
用例(Usage)
var WeChat = require('Kx-WeChat');
var wx = new WeChat(
{
"openid":"Your WeChat Openid",
"appsecret":"Your WeChat appsecret",
"token":"Your WeChat token",
"encodingaeskey":"Your WeChat encodingaeskey",
"debug":true
});
function _default(data){
return "The result of your processing";
}
function _replayUserTextMessage(data){
return "The result of your processing";
}
wx.AddEvent("default",_default);
wx.AddEvent("text",_replayUserTextMessage);
支持APIs(Support APIs)
Supports the following APIs:
- WeChat.AddEvent(eventName,callback)
- WeChat.MD5(source)
- WeChat.BuildReplyMsg(toUser,message)
- WeChat.GET(signature, timestamp, nonce, echostr)
- WeChat.POST = function(signature, timestamp, nonce, encryptStr)
AddEvent
方法说明: 注册微信消息的对应处理事件
eventName: 微信消息的 MsgType 详情
callback: 对应的 MsgType 会调用的function
MD5
方法说明: 对字符串进行MD5加密
source: 需要进行MD5的原始字符串
BuildReplyMsg
方法说明: 构建文本类的加密回复信息
toUser: 构建文本类的加密回复信息中的用户ID
message: 构建文本类的加密回复信息中的消息内容
GET
signature: 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。
timestamp: 时间戳
nonce: 随机数
echostr: 随机字符串
POST
signature: 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。
timestamp: 时间戳
nonce: 随机数
encryptStr: 安全模式下,第三方平台方收到的带密文消息体中Encrypt的字段内容
流程图 Flowchart
st=>start: 用户登陆
op=>operation: 登陆操作
cond=>condition: 登陆成功 Yes or No?
e=>end: 进入后台
st->op->cond
cond(yes)->e
cond(no)->op
序列图 Sequence Diagram
Andrew->China: Says Hello
Note right of China: China thinks\nabout it
China-->Andrew: How are you?
Andrew->>China: I am good thanks!