首页 > 代码库 > node.js 微信

node.js 微信

var crypto = require(‘crypto‘);  app.get(‘/api/wx/test‘,function(req,res){    if (req.query) {      var arr = [];      var signature = req.query["signature"];      var timestamp = req.query["timestamp"];      var nonce = req.query["nonce"];      var echostr = req.query["echostr"];      var token = ‘tjntv‘;      arr.push(token,timestamp,nonce);      arr.sort();      var str = arr.join(‘‘);      var md5sum = crypto.createHash(‘sha1‘);      str = md5sum.update(str);      if ( str == signature ) {        res.send(echostr);      } else {        console.log(‘22222222222222‘);      }    } else {      console.log(‘11111111111111‘);      return false;    }  });

  

node.js 微信