云函数名称
checkmsg
package.json:
{
“name”: “checkmsg”,
“version”: “1.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“test”: “echo \“Error: no test specified\” && exit 1”
},
“author”: “”,
“license”: “ISC”,
“dependencies”: {
“wx-server-sdk”: “latest”
}
}
config.json:
{
“permissions”: {
“openapi”: [
“security.msgSecCheck”
]
}
}
// 云函数入口文件
const cloud = require(‘wx-server-sdk’)
cloud.init()
// 云函数入口函数
exports.main = async(event, context) => {
const wxContext = cloud.getWXContext()
let checkresult
console.log(JSON.stringify(cloud.openapi))
try {
checkresult = await cloud.openapi.security.msgSecCheck({
“content”: “hello world!”
})
} catch (error) {
throw error
}
console.log(checkresult)
return true
}
开始时间
2019-07-31 12:08:17
时长
92.7ms
计费时长
100ms
调用完成
是
内存使用
16.19 MB
Request ID
d3097824-b348-11e9-b50b-525400dee61a
调用状态
失败, ret code 1
返回结果
{“errorCode”:1,“errorMessage”:“user code exception caught”,“stackTrace”:“errCode: -501007 invalid parameters | errMsg: security.msgSecCheck:fail Invalid request param”}
调用日志
START RequestId: d3097824-b348-11e9-b50b-525400dee61a
Event RequestId: d3097824-b348-11e9-b50b-525400dee61a
2019-07-31T04:08:17.960Z d3097824-b348-11e9-b50b-525400dee61a {}
Error: errCode: -501007 invalid parameters | errMsg: security.msgSecCheck:fail Invalid request param
at new CloudSDKError (/var/user/node_modules/wx-server-sdk/index.js:6360:28)
at Object.<anonymous> (/var/user/node_modules/wx-server-sdk/index.js:434:35)
at step (/var/user/node_modules/tslib/tslib.js:136:27)
at Object.next (/var/user/node_modules/tslib/tslib.js:117:57)
at fulfilled (/var/user/node_modules/tslib/tslib.js:107:62)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
END RequestId: d3097824-b348-11e9-b50b-525400dee61a
Report RequestId: d3097824-b348-11e9-b50b-525400dee61a Duration:92ms Memory:256MB MaxMemoryUsed:16.187500MB