希望通过小程序demo实现,用户评论的结果通知到用户自己。提交评价,评价成功则调用云函数。
调试基础库:2.14.1
云函数代码如下:
exports.main = async (event, context) => {
console.log("event", event)
const { OPENID } = cloud.getWXContext()
console.log("OPENID", OPENID)
const result = await cloud.openapi.subscribeMessage.send({
touser: OPENID,
page: `/pages/blog-comment/blog-comment?blogId=${event.blogId}`,
data: {
thing1: {
value: '评价完成'
},
thing2: {
value: event.content
}
},
template_id: '7zt83hMczrBmoptjry5n50sZ6JdkVcS4p3A706O9i_g',
})
console.log("结果", result)
return result
}
云函数可以被调用,event和OPENID都可以正常打印,报错返回结果:
{"errorCode":1,"errorMessage":"user code exception caught","stackTrace":"Error: errCode: 43101 | errMsg: openapi.subscribeMessage.send:fail user refuse to accept the msg rid: 5ff57464-05346540-27a2bba9
at callWXOpenAPI (/var/user/node_modules/wx-server-sdk/index.js:2378:31)
at process._tickCallback (internal/process/next_tick.js:68:7)","statusCode":430}
我很困惑的是43101这个报错看起来十分宽泛,我定位不到错误的地方。但无论是模拟器还是真机我都没有看到底部的授权通知。我不太明白为什么就“用户拒绝”了。路过的各位大佬麻烦指点一下,我可能哪里写错了,谢谢!
补充:小程序的设置里只有用户信息一栏:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…