nodejs关联公众号验证代码

 

微信开发文档

// 对接代码

const token = 'xxx', // 自定义,与公众号设置的一致 signature = ctx.query.signature, timestamp = ctx.query.timestamp, nonce = ctx.query.nonce // 字典排序 const arr = [token, timestamp, nonce].sort() const sha1 = crypto.createHash('sha1') sha1.update(arr.join('')) const result = sha1.digest('hex') if (result === signature) { ctx.body = ctx.query.echostr } else { ctx.body = { code: -1, msg: "fail" } }

 

posted @ 2019-04-18 14:49  大厨的笔记  阅读(291)  评论(0编辑  收藏  举报