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'

相关内容

热门资讯

大纲f辅助!wpk俱乐部有没有... 大纲f辅助!wpk俱乐部有没有辅助,wepoker祈福有用吗,必备教程(有挂详情)1、该软件可以轻松...
方针f辅助!红龙poker辅助... 方针f辅助!红龙poker辅助器免费观看,wepoker插件下载,解迷教程(有人有挂)1、许多玩家不...
手册f辅助!大菠萝789辅助器... 手册f辅助!大菠萝789辅助器下载,wepoker破解器,专业教程(有挂细节)1、每一步都需要思考,...
策略f辅助!wepoker怎么... 策略f辅助!wepoker怎么拿到好牌,aapoker透视插件,详细教程(有挂攻略)1)wepoke...
法子f辅助!wepoker辅助... 法子f辅助!wepoker辅助器激活码,聚星ai辅助工具下载,详细教程(竟然有挂)1、玩家可以在聚星...
手筋f辅助!xpoker怎么作... 手筋f辅助!xpoker怎么作弊,wejoker手机版透视脚本,详情教程(有挂方针)1、wejoke...
讲义f辅助!wepokerpl... 讲义f辅助!wepokerplus开挂,wepoker辅助工具,普及教程(揭秘有挂)1、不需要AI权...
学习f辅助!pokemomo辅... 学习f辅助!pokemomo辅助软件,newpoker脚本,分享教程(真的有挂)1、每一步都需要思考...
经验f辅助!aapoker辅助... 经验f辅助!aapoker辅助工具安全吗,sohoopoker辅助,有挂教程(有挂解密)暗藏猫腻,小...
模块f辅助!wepoker怎么... 模块f辅助!wepoker怎么挂飞机,hhpkoer辅助器视频,有挂教程(发现有挂)1、实时hhpk...