微信开放平台全网检测问题

clipboard.png

发送事件消息时微信需要回复Eventfrom_callback,Event需要替换为发送过来的值

const xmlObj = {
          ToUserName: data.FromUserName,
          FromUserName: data.ToUserName,
          CreateTime: timestamp,
          MsgType: 'text',
          Content: `${data.Event}from_callback`,
        };
        logger.info('回复事件', JSON.stringify(xmlObj));
        const xml = format(msgTpl, xmlObj.ToUserName, xmlObj.FromUserName, xmlObj.CreateTime, xmlObj.Content);
        const response = wxcrypto.buildMsgObject(xml);
        ctx.body = format(responseTpl, response.Encrypt, response.MsgSignature, response.TimeStamp, response.Nonce);

发送文本消息

      const xmlObj = {
            ToUserName: data.FromUserName,
            FromUserName: data.ToUserName,
            CreateTime: timestamp,
            MsgType: 'text',
            Content: `TESTCOMPONENT_MSG_TYPE_TEXT_callback`,
          };
          logger.info('回复文本', JSON.stringify(xmlObj));
          const xml = format(msgTpl, xmlObj.ToUserName, xmlObj.FromUserName, xmlObj.CreateTime, xmlObj.Content);
          const response = wxcrypto.buildMsgObject(xml);
          ctx.body = format(responseTpl, response.Encrypt, response.MsgSignature, response.TimeStamp, response.Nonce);

逻辑代码一样的。除了Content字段。
结果事件消息死活不通过。我是没辙了

阅读 3.3k
1 个回答

回复事件消息加密了吗?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进