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'

相关内容

热门资讯

透视实锤!werplan辅助软... 透视实锤!werplan辅助软件,wepoker辅助工具,项目教程(有挂工具)-哔哩哔哩1、进入到w...
透视透视挂!wepoker俱乐... 透视透视挂!wepoker俱乐部辅助(透视)都是真的有挂,力荐教程(有挂大厅)-哔哩哔哩1、下载好w...
6分钟详情!wejoker私人... 6分钟详情!wejoker私人辅助软件(透视)竟然是有挂,我来教教你(有人有挂)-哔哩哔哩1、wej...
透视了解!wepoker破解器... 透视了解!wepoker破解器激活码,wepoker破解是真的还是假的,总结教程(有挂头条)-哔哩哔...
透视辅助!wepoker底牌透... 透视辅助!wepoker底牌透视(透视)果然真的是有挂,2025新版教程(有挂代打ai)-哔哩哔哩1...
7分钟解谜!wepoker黑侠... 7分钟解谜!wepoker黑侠破解(透视)本来有挂,德州论坛(有挂详细)-哔哩哔哩1、wepoker...
透视了解!wejoker辅助脚... 透视了解!wejoker辅助脚本,steampokermaster辅助,指引教程(有挂教学)-哔哩哔...
透视软件!wepoker一直输... 透视软件!wepoker一直输的号能继续打吗(透视)切实是有挂,黑科技教程(有挂猫腻)-哔哩哔哩小薇...
7分钟解迷!wepoker透视... 7分钟解迷!wepoker透视破解版(透视)一直有挂,详细教程(确实有挂)-哔哩哔哩1、任何wepo...
透视app!hhpoker有没... 透视app!hhpoker有没有辅助,wpk有那种辅助吗,大纲教程(有人有挂)-哔哩哔哩暗藏猫腻,小...