Node.js 微信公众号-基本配置-服务器URL
创始人
2025-01-17 00:02:29
0

1、验证签名

在提交配置时,服务器对应的URL需要实现签名的验证,成功时,需要直接返回 echostr 的值,注意此时URL对应的接口为get请求

const { signature, timestamp, nonce, echostr } = _req.query;

const token = "my_token"; // 公众号配置时的Token

const tmpArr = [token, timestamp, nonce];

tmpArr.sort();

// 引入加密模块

const crypto = require('crypto');

// 创建哈希对象

const sha1Hash = crypto.createHash('sha1');

// console.log("排序后连接:", tmpArr.join(""))

sha1Hash.update(tmpArr.join(""));

const hashedData = sha1Hash.digest('hex');

// console.log(hashedData, signature);

if (hashedData == signature) {

res.end(echostr);

}

2、消息推送

在用户操作时(关注、取消关注、扫描公众号二维码码等操作时),微信公众号会发送消息到基本配置中的URL对应的接口,注意此时URL对应的接口为post请求,也就是说URL对应的接口需要同时支持get和post请求。而且需要在IP白名单中添加服务器的IP地址。

3、完整示例

// router.js

varapi = require('./api'

相关内容

热门资讯

据玩家消息!wepoker透视... 据玩家消息!wepoker透视底牌脚本,wepoker私人局外卦(透视)指南教程(一直是有挂)1、w...
透视揭露!we-poker辅助... 透视揭露!we-poker辅助(透视)wepoker买脚本靠谱吗,教程方式(确实有挂)-哔哩哔哩1....
最新消息!aapoker俱乐部... 最新消息!aapoker俱乐部靠谱吗,wepokerplus开挂(透视)模块教程(确实真的是有挂)1...
透视推荐!hhpkoer辅助器... 透视推荐!hhpkoer辅助器(透视)pokermaster修改器,教程窍要(有挂细节)-哔哩哔哩1...
截至目前!hhpoker德州机... 截至目前!hhpoker德州机器人,wepoker怎么获得好牌(透视)妙招教程(切实是有挂)一、we...
透视揭露!wepoker怎么挂... 透视揭露!wepoker怎么挂飞机(透视)德普之星透视辅助软件激活码,教程操作(有挂工具)-哔哩哔哩...
昨日!aapoker插件下载,... 昨日!aapoker插件下载,智星德州辅助译码插件靠谱吗(透视)方案教程(好像真的是有挂)昨日!aa...
透视开挂!哈糖大菠萝破解器(透... 透视开挂!哈糖大菠萝破解器(透视)wejoker辅助软件视频,教程秘籍(有挂攻略)-哔哩哔哩1、打开...
透视开挂!hhpoker透视码... 透视开挂!hhpoker透视码怎么用(透视)hhpoker智能辅助插件,教程经验(有挂细节)-哔哩哔...
此事迅速冲上热搜!pokemo... 此事迅速冲上热搜!pokemomo辅助工具,约局吧德州真的存在透视吗(透视)教材教程(一贯是有挂)1...