node(koa)微信公众号接口认证
2024-08-31 01:20:22
使用微信测试号, 花生壳内网穿透
需要注意 token 两边都是自定义, 需要保持一致,
const Koa = require('koa')
const sha1 = require('sha1') const app = new Koa() const config = {
wechat: {
appID: '', //填写你自己的appID
appSecret: '', //填写你自己的appSecret
token: '' //填写你自己的token
}
} app.use(async (ctx) => {
const token = config.wechat.token
const signature = ctx.request.query.signature
const nonce = ctx.request.query.nonce
const timestamp = ctx.request.query.timestamp
const echostr = ctx.request.query.echostr
let str = [token, timestamp, nonce].sort().join('')
const sha = sha1(str)
ctx.body = sha === signature ? echostr + '' : 'failed'
}) app.listen(, () => {
console.log('node started port 8999')
})
微信测试号地址 点击验证 显示配置成功即可
最新文章
- NginxWeb服务器安装
- windows多线程编程实现 简单(1)
- Linux FHS
- leetcode 419
- Java 创建xml文件和操作xml数据
- python list求交集
- lightoj 1064 Throwing Dice
- Linux-C语言中gettimeofday()函数的使用方法(转载)
- VC/MFC 工具栏上动态添加组合框等控件的方法
- Android_app项目开发步骤总结
- perl-cgi命令行调试
- 强化学习读书笔记 - 02 - 多臂老O虎O机问题
- 【Egret】Lakeshore 使用中的一些疑难解决技巧!
- 业务与IT技术
- C语言strcpy,strncpy和strlcpy讲解
- Linux文件系统备份
- 如何利用一台pc获取百万利益 《标题党》
- 03 Zabbix常用的术语
- PAT L3-010 是否完全二叉搜索树(二叉搜索树)
- 安装win8/win10提示无法在驱动器0分区上安装windows解决方法