函数执行成功(耗时 974ms) Error: errCode: 40037 | errMsg: openapi.uniformMessage.send:fail invalid template_id rid: 610902a6-020c21d9-4f4ff6f6
at callWXOpenAPI (E:\WeChatProject\miniprogram-message\cloudfunctions\messageSend\node_modules\wx-server-sdk\index.js:2392:31)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async u.exports.main [as handler] (E:\WeChatProject\miniprogram-message\cloudfunctions\messageSend\index.js:8:20)
我的消息模板是:
"templateId": 'sjuKoy0ROy6oy7pCJwEEwHI-oOGsxxg1w947ZDTsfK8'
小程序 "appid": 'wxa5e84ef1c0f19775',
公众号appid: "appid": 'wxe590a6b3ee3ba316'
模板ID错误,模板id必须是 wxe590a6b3ee3ba316 下面的
下面是程序代码:
const cloud = require('wx-server-sdk')
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV,
})
exports.main = async (event, context) => {
try {
const wxContext = cloud.getWXContext()
const result = await cloud.openapi.uniformMessage.send({
"touser": wxContext.OPENID,
/*
"weappTemplateMsg": {
},
**/
"mpTemplateMsg": {
"appid": 'wxe590a6b3ee3ba316', //黄骅公交微信公众号APPID
"url": 'http://weixin.qq.com/download',
"miniprogram": {
"appid": 'wxa5e84ef1c0f19775',
"pagepath": 'index'
},
"data": {
"date1": {
"value": "2021-08-03 17:16:00",
"color": '#173177'
},
"thing6": {
"value": '2路',
"color": '#173177'
},
"car_number3": {
"value": '11234',
"color": '#173177'
},
"thing4": {
"value": '为避免错过车,请提前15分钟到达上车站点等候',
"color": '#173177'
}
},
"templateId": 'sjuKoy0ROy6oy7pCJwEEwHI-oOGsxxg1w947ZDTsfK8'
}
})
return result
} catch (err) {
return err
}
}