输出内容:
配置成功后输出
sha = 63b7ad58d28ecb1a87da4de3e6be9eaa6e19f6bc signature = 63b7ad58d28ecb1a87da4de3e6be9eaa6e19f6bc
打开浏览器地址输出
sha = 9fa71d753282f94f85eca97d45811ce60ead189f signature = undefined sha = 9fa71d753282f94f85eca97d45811ce60ead189f signature = undefined
app.js 源码
app.use( function *(next){ // console.log(this.query); var token = config.wechat.token; var signature = this.query.signature; var nonce = this.query.nonce; var timestamp = this.query.timestamp; var echostr = this.query.echostr; var str = [token, timestamp, nonce].sort().join(''); var sha = sha1(str); console.log('str = ' + str); console.log('signature = ' + signature); if(sha === signature){ this.body = echostr + ''; } else { this.body = 'wrong'; } } )