收藏
回答

如何使用subscribeMessage.send,一直出现errCode: -604101?

代码部分如下:

try {
    const { touser, templateID, data } = event;
    console.log("touser",touser,"templateID",templateID,"data",data);


    // 调用微信开放接口发送订阅消息
    const result = await cloud.openapi.subscribeMessage.send({
      touser: touser, // 接收者的 OpenID
      templateId: templateID, // 订阅消息模板 ID
      datadata// 模板内容
      page:'pages/index/index'
    });


    return {
      code: 0,
      message: '订阅消息发送成功',
      data: result
    };
  } catch (err) {
    console.error('订阅消息发送失败', err);
    return {
      code: -1,
      message: '订阅消息发送失败',
      error: err
    };
  }


报错信息如下:

2025-01-27T16:13:32.939Z touser o1Cfu6__WEwyqjysmbbSTUJIyQIc templateID CZRLjGeXUez11VXsH5diJgybbPat8F_8Z_Q05DOTQDc data { thing1: { value: '有新评论' } }

2025-01-27T16:13:33.171Z 订阅消息发送失败 CloudSDKError: errCode: -604101 function has no permission to call this API | errMsg: system error: error code: -604101

at callGeneralOpenAPI (/var/user/node_modules/wx-server-sdk/index.js:487:27)

at processTicksAndRejections (node:internal/process/task_queues:96:5)

at async callWXOpenAPI (/var/user/node_modules/wx-server-sdk/index.js:2364:28)

at async exports.main (/var/user/index.js:16:20) {

errCode: -604101,

errMsg: 'system error: error code: -604101'

}

Response RequestId: 025ed385-ae9f-4b8c-a9fd-54f608acdc41 RetMsg: {"code":-1,"message":"订阅消息发送失败","error":{"errCode":-604101,"errMsg":"system error: error code: -604101"}}

关键是昨天我在想用延时调用云函数的时候,也出现了同样的错误码:CloudSDKError: errCode: -604101 function has no permission to call this API

我在云函数config.json里都进行了设置,请问到底是怎么回事呀?

回答关注问题邀请回答
收藏

1 个回答

  • 管名豪
    管名豪
    2天前

    我的config


    我最后根据其他帖子的经验,确实发现模拟器上不行,真机上却可以。

    2天前
    有用
    回复
登录 后发表内容