-
Notifications
You must be signed in to change notification settings - Fork 22
处理用户发送过来的消息
Eric edited this page Apr 19, 2016
·
2 revisions
在公共帐号里处理用户发送过来的消息
var messages = nodeWeixinMessage.messages;
function A(message, res, cb, more) {
res.send();
cb();
}
messages.on.link(A);
app.get('/link', function(req, res) {
messages.onXML(req.body, res, function callback() {
// 处理完成后可以返回
},
'and more');
}
//处理接收消息
//需要通过parse分析消息,然后再通知相应的处理方法,这个代码需要放在ack服务器的返回处理
//接收文本
messages.on.text(function(message, res, cb) {
//message.FromUserName
//message.ToUserName
//message.CreateTime
//message.MsgType
//message.Content
//message.MsgId
res.send();
cb();
});
//接收图片
messages.on.image(function(message, res, cb) {
//message.FromUserName
//message.ToUserName
//message.CreateTime
//message.MsgType
//message.PicUrl
//message.MediaId
//message.MsgId
res.send();
cb();
});
//接收语音
messages.on.voice(function(message, res, cb) {
//message.FromUserName
//message.ToUserName
//message.CreateTime
//message.MsgType
//message.Format
//message.Recognition
//message.MediaId
//message.MsgId
res.send();
cb();
});
//接收视频
messages.on.video(function(message, res, cb) {
//message.FromUserName
//message.ToUserName
//message.CreateTime
//message.MsgType
//message.ThumbMediaId
//message.MediaId
//message.MsgId
res.send();
cb();
});
//接收短视频
messages.on.shortvideo(function(message, res, cb) {
//message.FromUserName
//message.ToUserName
//message.CreateTime
//message.MsgType
//message.ThumbMediaId
//message.MediaId
//message.MsgId
res.send();
cb();
});
//接收位置信息
messages.on.location(function(message, res, cb) {
//message.FromUserName
//message.ToUserName
//message.CreateTime
//message.MsgType
//message.Location_X
//message.Location_Y
//message.Scale
//message.Label
//message.MsgId
res.send();
cb();
});
//接收链接
messages.on.link(function(message, res, cb) {
//message.FromUserName
//message.ToUserName
//message.CreateTime
//message.MsgType
//message.Title
//message.Description
//message.Url
//message.MsgId
res.send();
cb();
});