目前我在做社交类的小程序,想接入内容安全检测,目前我的实现方式是:
- 调用 uni.login拿到 code
- 用 code 调用微信接口换取 openid
- 调用自己封装的 uniClound 的云对象,这个云对象引入uni-sec-check模块,实现文本识别
我现在已经拿到了openid,调用自己的云对象的时候微信开发工具报错:
Error: [obj-sec-check]: 40013:invalid appid rid: 66d8006c-44320492-361293dd
at new te (vendor.js?t=wechat&s=1724978575227&v=4fcf0d1de9b969a70c3e0891fed56a4f:8273)
at s4 (vendor.js?t=wechat&s=1724978575227&v=4fcf0d1de9b969a70c3e0891fed56a4f:10334)
at async Proxy.<anonymous> (vendor.js?t=wechat&s=1724978575227&v=4fcf0d1de9b969a70c3e0891fed56a4f:10287)(env: macOS,mp,1.06.2407120; lib: 3.5.5)
云对象错误日志:
请求入参: {
"args": {
"method": "textSecCheck",
"params": [
{
"content": "哈哈哈",
"openid": "ofNZn5I8Fx-yn2URKB8rYaH4kWgA"
}
],
"clientInfo": {
"PLATFORM": "mp-weixin",
"OS": "ios",
"APPID": "__UNI__9D1446A",
"DEVICEID": "1724748071714401339",
"scene": 1001,
"deviceId": "1724748071714401339",
"appId": "__UNI__9D1446A",
"appName": "poison-chicken-soup-everyday",
"appVersion": "1.0.7",
"appVersionCode": 2021040904,
"appLanguage": "zh-Hans",
"uniRuntimeVersion": "4.24",
"uniPlatform": "mp-weixin",
"deviceBrand": "devtools",
"deviceModel": "iPhone XS Max",
"deviceType": "phone",
"osName": "ios",
"osVersion": "10.0.1",
"hostVersion": "8.0.5",
"hostName": "WeChat",
"locale": "zh-Hans",
"LOCALE": "zh-Hans"
}
},
"requestId": "ac1cc31a1725431915912140899"
}
[obj-sec-check/ac1cc31a1725431915912140899/54ms/DEBUG] requestId输出: ac1cc31a1725431915912140899
[obj-sec-check/ac1cc31a1725431915912140899/281ms/DEBUG] WeixinServer::response {
data: {
errcode: 40013,
errmsg: 'invalid appid rid: 66d8006c-44320492-361293dd'
},
status: 200,
headers: {
connection: 'keep-alive',
date: 'Wed, 04 Sep 2024 06:38:36 GMT',
'content-type': 'application/json; encoding=utf-8',
retkey: '11',
logicret: '40013',
'content-length': '74'
},
res: {
status: 200,
statusCode: 200,
statusMessage: 'OK',
headers: {
connection: 'keep-alive',
date: 'Wed, 04 Sep 2024 06:38:36 GMT',
'content-type': 'application/json; encoding=utf-8',
retkey: '11',
logicret: '40013',
'content-length': '74'
},
size: 74,
aborted: false,
rt: 151,
keepAliveSocket: false,
data: {
errcode: 40013,
errmsg: 'invalid appid rid: 66d8006c-44320492-361293dd'
},
requestUrls: [ 'https://api.weixin.qq.com/cgi-bin/stable_token' ],
timing: null,
remoteAddress: '101.89.47.18',
remotePort: 443,
socketHandledRequests: 1,
socketHandledResponses: 1
}
}
[obj-sec-check/ac1cc31a1725431915912140899/286ms/ERROR] invalid appid rid: 66d8006c-44320492-361293dd
Error: invalid appid rid: 66d8006c-44320492-361293dd
at Function.WeixinServer.GetResponseData (/tmp/function/@common_modules/uni-open-bridge-common/weixin-server.js:151:11)
at Function.WeixinServer.GetMPAccessTokenData (/tmp/function/@common_modules/uni-open-bridge-common/weixin-server.js:159:23)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async AccessToken.getByWeixinServer (/tmp/function/@common_modules/uni-open-bridge-common/index.js:56:26)
at async CacheKey.get (/tmp/function/@common_modules/uni-open-bridge-common/uni-cloud-cache.js:235:28)
at async AccessToken.get (/tmp/function/@common_modules/uni-open-bridge-common/storage.js:24:20)
at async WxOpenapi.getAccessToken (/tmp/function/@common_modules/uni-sec-check/platform/mp-weixin/index.js:35:20)
at async WxOpenapi._requestWxApi (/tmp/function/@common_modules/uni-sec-check/platform/mp-weixin/index.js:40:25)
at async Proxy.<anonymous> (/tmp/function/@common_modules/uni-sec-check/utils/create-api.js:40:24)
at async i.textSecCheck (/tmp/function/index.obj.js:12:20)
请求响应状态: fail
obj-sec-check云对象代码:
const UniSecCheck = require('uni-sec-check');
module.exports = {
//文本安全校验方法textSecCheck({文本内容,openid,场景值,接口版本})
async textSecCheck({content,openid,scene=2,version=2} = {}){
const requestId = this.getUniCloudRequestId()
console.log("requestId输出:", requestId)
const uniSecCheck = new UniSecCheck({
provider: 'mp-weixin',
requestId, // 云函数内则写 context.requestId
});
const checkRes = await uniSecCheck.textSecCheck({
content,
openid,
scene,
version
})
if (checkRes.errCode === 'uni-sec-check-risk-content') {
return {
code: 400,
errMsg: '内容不合规',
result: checkRes.result
}
}else if(checkRes.errCode){
return {
code: 400,
errMsg: checkRes.errMsg,
result: checkRes.result
}
}
return {
errCode: 0,
errMsg: ''
};
}
}
uni-config-center中也配置了appid和appsecret,在附件的截图中
uni_modules中的包我也做了更新
麻烦各界大佬帮忙看看是我哪做的还有问题?
TS_凤凤 (作者)
果然,这个没上传,感谢大佬,祝大佬升职加薪
2024-09-04 17:34