消息推送主要利用到了“發(fā)送客服消息”的接口(http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html)。
根據(jù)文檔我們可以得知該接口可以發(fā)送:文本消息有滑、圖片消息、語音消息、視頻消息、音樂消息彭雾、圖文消息沪铭。
下面將以文本消息作為例子來講解如何用node-wechat進(jìn)行消息推送。
安裝與配置wechat-api
$ npm install wechat-api
var WechatAPI = require('wechat-api');
var api = new WechatAPI(appid, appsecret);
api.updateRemark('open_id', 'remarked', function (err, data, res) {
// TODO
});
使用api.sendText接口發(fā)送消息
api.sendText(openid, msg, function(err, result) {
// TODO
});
最后就坐等收到提示消息了峦朗。
Paste_Image.png