关于调用云函数发送模板消息总是失败
openid和form_id都是同一用户的,但调用官方提供的例子,总是返回 "errCode":41028,"errMsg":"openapi.templateMessage.send:fail invalid form id hint: [DUJcrA09814126]" 折腾了大半天,都不知道原因在哪里,到这里寻求一下帮助。 这是云函数 [代码]const cloud = require([代码][代码]'wx-server-sdk'[代码][代码])[代码][代码]cloud.init()[代码][代码]exports.main = async (event, context) => {[代码][代码] [代码][代码]try[代码] [代码]{[代码][代码] [代码][代码]const result = await cloud.openapi.templateMessage.send({[代码][代码] [代码][代码]touser: event.openid,[代码][代码] [代码][代码]template_id: event.msgid,[代码][代码] [代码][代码]page: event.page,[代码][代码] [代码][代码]form_id: event.formid,[代码][代码] [代码][代码]data: event.msgData,[代码][代码] [代码][代码]emphasisKeyword: [代码][代码]'keyword2.DATA'[代码][代码] [代码][代码]})[代码][代码] [代码][代码]console.log(result)[代码][代码] [代码][代码]return[代码] [代码]result[代码][代码] [代码][代码]} [代码][代码]catch[代码] [代码](err) {[代码][代码] [代码][代码]console.log(err)[代码][代码] [代码][代码]return[代码] [代码]err[代码][代码] [代码][代码]}[代码][代码]}[代码]这是调用代码: [代码]console.log([代码][代码]'openid:'[代码] [代码]+ that.data.messages[that.data.index2]._openid) [代码][代码] [代码][代码]console.log([代码][代码]'form_id:'[代码] [代码]+ that.data.messages[that.data.index2].form_id) [代码][代码] [代码][代码]wx.cloud.callFunction({[代码][代码] [代码][代码]name: [代码][代码]'send'[代码][代码],[代码][代码] [代码][代码]data: { [代码][代码] [代码][代码]openid: that.data.messages[that.data.index2]._openid, [代码][代码] [代码][代码]msgid: [代码][代码]'eBnlQKSCORuwkctGXnrPLBoX2MxhGLI8aCZFz4S65e8'[代码][代码],[代码][代码]//模板id[代码][代码] [代码][代码]page: [代码][代码]'index?no='[代码] [代码]+ that.data.messages[that.data.index2].no,[代码][代码] [代码][代码]form_id: that.data.messages[that.data.index2].form_id,[代码][代码] [代码][代码]msgData: {[代码][代码] [代码][代码]"keyword1"[代码][代码]: { [代码][代码]"value"[代码][代码]: db.serverDate(), [代码][代码]"color"[代码][代码]: [代码][代码]"#173177"[代码] [代码]},[代码][代码] [代码][代码]"keyword2"[代码][代码]: { [代码][代码]"value"[代码][代码]: that.data.inputContent, [代码][代码]"color"[代码][代码]: [代码][代码]"#173177"[代码] [代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码][代码] [代码][代码]success: res => {[代码][代码] [代码][代码]wx: wx.showToast({[代码][代码] [代码][代码]title: [代码][代码]'推送消息成功'[代码][代码],[代码][代码] [代码][代码]icon: [代码][代码]'none'[代码][代码] [代码][代码]})[代码][代码] [代码][代码]console.log(res)[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]fail: e => {[代码][代码] [代码][代码]console.error([代码][代码]'[失败:'[代码][代码], e) [代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码]