小程序
小游戏
企业微信
微信支付
扫描小程序码分享
如下图:
appID为wxaa0fd8e7b03bd9ec
最近操作时间为20191221 2123
请帮忙解决下,谢谢!
4 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
https://blog.csdn.net/qq_40985294/article/details/105257416
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
米法(BINNIE SMILE) 谢谢,代码如下:
控制器代码:
import { Controller, Get, Header, Query } from '@nestjs/common'; import { WechatService } from './wechat.service'; @Controller('wechat') export classWechatController{ constructorprivate readonly wechatService: WechatService) {} @Get() @Header('Access-Control-Allow-Origin', '*') @Header('Access-Control-Allow-Headers', 'X-Requested-With') @Header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS') @Header('X-Powered-By', '3.2.1') @Header('Content-Type', 'text/plain;charset=utf-8') public async receiveMsgFromWechat( @Query() query, ) { const result = this.wechatService.verify( query.signature, query.timestamp, query.nonce, query.echostr, ); // console.log(`query is ${JSON.stringify(query)}`); let res; if (result['isPass']) { // res = { // status: 200, // body: result['data'], // }; return result['data']; } else { res = { status: '403', msg: result['message'], }; console.log('res类型是', typeof res); return res; } } }
服务:
import { Injectable } from'@nestjs/common'; import * as crypto from'crypto'; @Injectable() exportclass WechatService { // 验证 public verify = signature, timestamp, nonce, echostr) => { // 约定token const config = { wechat: { appID: '', appsecret: '', token: '', }, }; // 生成密钥 const token = config.wechat.token; const str = [token, timestamp, nonce].sort().join(); const sha1Code = crypto.createHash('sha1'); const sha = sha1Code.update(str, 'utf8').digest('hex'); let result = {}; console.log('检查signature和sha', signature, sha); if (sha === signature) { // 成功 result['isPass'] = true; result['data'] = echostr; } else { // 失败 result['isPass'] = false; result['message'] = '验证失败!重新再试'; } return result; }; }
进程管理使用pm2,在验证服务器的时候,没有打印日志
:(
你好,提供下appid,URL已经操作时间
我也是遇到了这个原因 签名通过了也返回了相应的echostr 都没用
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
https://blog.csdn.net/qq_40985294/article/details/105257416
米法(BINNIE SMILE) 谢谢,代码如下:
控制器代码:
import { Controller, Get, Header, Query } from '@nestjs/common'; import { WechatService } from './wechat.service'; @Controller('wechat') export classWechatController{ constructorprivate readonly wechatService: WechatService) {} @Get() @Header('Access-Control-Allow-Origin', '*') @Header('Access-Control-Allow-Headers', 'X-Requested-With') @Header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS') @Header('X-Powered-By', '3.2.1') @Header('Content-Type', 'text/plain;charset=utf-8') public async receiveMsgFromWechat( @Query() query, ) { const result = this.wechatService.verify( query.signature, query.timestamp, query.nonce, query.echostr, ); // console.log(`query is ${JSON.stringify(query)}`); let res; if (result['isPass']) { // res = { // status: 200, // body: result['data'], // }; return result['data']; } else { res = { status: '403', msg: result['message'], }; console.log('res类型是', typeof res); return res; } } }
服务:
import { Injectable } from'@nestjs/common'; import * as crypto from'crypto'; @Injectable() exportclass WechatService { // 验证 public verify = signature, timestamp, nonce, echostr) => { // 约定token const config = { wechat: { appID: '', appsecret: '', token: '', }, }; // 生成密钥 const token = config.wechat.token; const str = [token, timestamp, nonce].sort().join(); const sha1Code = crypto.createHash('sha1'); const sha = sha1Code.update(str, 'utf8').digest('hex'); let result = {}; console.log('检查signature和sha', signature, sha); if (sha === signature) { // 成功 result['isPass'] = true; result['data'] = echostr; } else { // 失败 result['isPass'] = false; result['message'] = '验证失败!重新再试'; } return result; }; }
进程管理使用pm2,在验证服务器的时候,没有打印日志
:(
你好,提供下appid,URL已经操作时间
URL操作时间为 2019-12-26 15:42:23
appid:wx34e624657593d1c1
URL:http://wx.steelbull.cn
操作时间:2022-06-01 18:08:41
我也是遇到了这个原因 签名通过了也返回了相应的echostr 都没用