const Koa = require('koa');
const app = new Koa();
const sha1 = require('sha1');
const config = {
wechat: {
appID: '**',
appSecret: '**',
token: '**'
}
}
app.use(function *(){
console.log(this.query);
const token = config.wechat.token;
const signature = this.query.signature;
const timestamp = this.query.timestamp;
const nonce = this.query.nonce;
const echostr = this.query.echostr;
let str = [token,timerstamp,nonce].sort().join('');
const sha = sha1(str);
if( sha === signature){
this.body = echostr;
}else{
this.body = 'wrong';
}
})
node 开发公众号 服务端 验证用户参数
最新推荐文章于 2024-11-29 19:03:07 发布
本文介绍使用Koa.js框架实现微信公众号接口的验证过程,包括如何获取和校验微信服务器推送的签名signature,以及如何响应echostr参数,确保微信服务器能够成功验证公众号的合法性。
1157

被折叠的 条评论
为什么被折叠?



