没有不值得去解决的问题,也没有不值得去学习的技术!

Troubleshooting the WeChat Mini Program API for Generating Unlimited Mini Program Codes

I set the request parameter "check_path" to false, which resolved the issue. Then another error occurred: Unrecognized format ''

1. When requesting the WeChat Mini Program API: get unlimited mini program code, an error occurred: errcode: 47001, errmsg: data format error rid. See Figure 1.

When requesting the WeChat Mini Program API: get unlimited mini program code, an error occurred: errcode: 47001, errmsg: data format error rid
Figure 1
Plaintext

POST https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={token}
Content-Type: application/x-www-form-urlencoded; charset=UTF-8

scene=1825203750690640&page=pages%2Findex%2Findex

2. I adjusted the Content-Type of the request parameters, which resolved the issue. Then another error occurred: errcode: 41030, errmsg: invalid page rid. See Figure 2.

I adjusted the Content-Type of the request parameters, which resolved the issue. Then another error occurred: errcode: 41030, errmsg: invalid page rid
Figure 2
Plaintext

POST https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={token}
Content-Type: application/json; charset=UTF-8

{"scene":"1825203750690640","page":"pages\/index\/index","width":null}

3. I set the request parameter “check_path” to false, which resolved the issue. Then another error occurred: Unrecognized format ”. See Figure 3.

I set the request parameter "check_path" to false, which resolved the issue. Then another error occurred: Unrecognized format ''
Figure 3
Plaintext

POST https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={token}
Content-Type: application/json; charset=UTF-8

{"scene":"1825203750690640","page":"pages\/index\/index","width":null,"check_path":false}

4. I changed the response format to raw-urlencoded, which resolved the issue.

PHP

        $response = $this->httpClient->createRequest()
            ->setMethod('POST')
            ->setUrl('wxa/getwxacodeunlimit?access_token=' . $accessToken)
            ->setFormat(Client::FORMAT_JSON)
            ->setData([
                'scene' => $scene,
                'page' => $page,
                'width' => $width,
                'check_path' => false,
                'env_version' => 'trial'
            ])
            ->send();

        // 设置响应格式为 raw-urlencoded(二进制数据)
        $response->format = Client::FORMAT_RAW_URLENCODED;

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系