收藏
回答

小程序使用云函数调用服务号创建渠道二维码报错48001,已经有生成带参数的二维码权限,是啥问题呢?

1.已经有接口权限。

2.服务号已认证。

3.小程序和服务号是同一个主体。在小程序里面用云函数调用officialAccount.qrcode.create接口,创建公众号带参数的二维码。

4.报错信息如下:

--------

errMsg: "cloud.callFunction:ok"

requestID: "1429eb0a-6397-4fb4-aab4-5675df2ba247"

result:

error:

errCode: 48001

errMsg: "openapi.officialAccount.qrcode.create:fail api unauthorized rid: 69476dc2-2bd7acf0-3ab73db8"

---------

5.云函数权限和wx-sdk版本如下:

{

  "permissions": {

    "openapi": [

      "wxacode.get",

      "officialAccount.qrcode.create"

    ]

  }

}

--------

  "dependencies": {

    "wx-server-sdk": "latest"

  }

6.云函数调用代码如下:

// 生成二维码(使用云调用)

async function generateQRCodeByCloudCall(qrType, sceneStr, expireSeconds) {

  try {

    let result;

    

      result = await cloud.openapi.officialAccount.qrcode.create({

        expire_seconds: expireSeconds,

        action_name: 'QR_STR_SCENE',

        action_info: {

          scene: { scene_str: sceneStr }

        }

      });

  

    // 直接构建微信官方二维码URL

    const qrUrl = `https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=${encodeURIComponent(result.ticket)}`

     return {

      success: true,

      ticket: result.ticket,

      expire_seconds: result.expire_seconds,

      url: result.url,        // 微信跳转URL

      qrUrl: qrUrl,          // 二维码图片URL

      qrCode: result          // 完整返回数据

    }

  } catch (error) {

    console.error('生成二维码失败:', error)

    return {

      success: false,

      error: error,

      try_catch: "yes"

    }

  }

}

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

1 个回答

  • 智能回答 智能回答 本次回答由AI生成
    2025-12-21
    有用
    回复 3
    • Wookin
      Wookin
      2025-12-21
      这个AI太烂了,第一个截图里面就显示了“带参数的二维码”有权限的。另外使用的云开发,不需要设置ip白名单的。
      2025-12-21
      回复
    • 智能回答 智能回答 本次回答由AI生成
      2025-12-21回复Wookin
    • Wookin
      Wookin
      2025-12-21回复Wookin
      你回去学习吧,第一张截图已经展示了接口权限状态。12月1号开始,你们设置页面已经变为了“接口权限与额度”
      2025-12-21
      回复
登录 后发表内容