云函数调用msgSecCheck接口报错
-本地调试时报错:module.exports.ReadError: incorrect header check
云端上调试也是这个报错:{“errorCode”:1,“errorMessage”:“user code exception caught”,“stackTrace”:“incorrect header check”}
- 确认了我的access_token没有问题,依赖库全部装上,
同样的函数,换了别的接口,对接成功,换回’https://api.weixin.qq.com/wxa/msg_sec_check?access_token=" 就依然不行
然后我就用postman测试https://api.weixin.qq.com/wxa/msg_sec_check?access_token=接口,对接成功,我复制了对接成功的POST地址放回云函数再次调试,依然报错,这是为啥?
开发工具版本是最新的 v1.02.1906062
-大佬们能给看看嘛,救救孩子
云函数的代码
// 云函数入口文件const cloud = require('wx-server-sdk');const got=require('got');var appid ='appid';var appsecret ='appsecret '; cloud.init();// 拼接 access_token let tokenUrl = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' + appid + '&secret=' + appsecret// 内容检测接口let checkUrl = 'https://api.weixin.qq.com/wxa/msg_sec_check?access_token='// 云函数入口函数exports.main = async (event, context) => { let tokenResponse = await got(tokenUrl); let token = JSON.parse(tokenResponse.body).access_token; let checkResponse = await got(checkUrl + token, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ content: event.content }) }); return checkResponse.body;} |
