`

Nodejs 微信开发 新用户关注事件

阅读更多

 

$ npm install wechat --save

 

 

关注事件代码片段:

var router = express.Router();
  router.use('/wechat', wechat('wechatToken', function (req, res, next) {
    // 微信输入信息都在req.weixin上
    var message = req.weixin;

    if((message.MsgType == 'event') && (message.Event == 'subscribe')) {
      var refillStr = "<a href=\"http://your_IP/weixin/refill?weixinId=" + message.FromUserName + "\">1. 点击记录团队充值"+message.ToUserName+"</a>"
      var consumeStr = "<a href=\"http://your_IP/weixin/consume?weixinId=" + message.FromUserName + "\">2. 点击记录团队消费"+message.FromUserName+"</a>"
      var deleteStr = "<a href=\"http://your_IP/weixin/delete?weixinId=" + message.FromUserName + "\">3. 点击回退记录"+message.MsgType+"</a>"
      var historyStr = "<a href=\"http://your_IP/weixin/history?weixinId=" + message.FromUserName + "\">4. 点击查询历史记录"+message.Event+"</a>"

      var emptyStr = "          ";
      var replyStr = "感谢你的关注!" + "\n"+ emptyStr + "\n" + refillStr + "\n"+ emptyStr + "\n" + consumeStr
        + "\n"+ emptyStr + "\n" + deleteStr + "\n"+ emptyStr + "\n" + historyStr;
      res.reply(replyStr);
    }
  }));

 

效果图:

  • 大小: 152.3 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics