May 19, 2021 WeChat Mini Program Development Document
This interface should be called on the server side, as detailed in the Service Side API.
This interface supports cloud calls. Developer tool version required . . . 1.02.1904090 (latest stable download)
wx-server-sdk >= 0.4.0
Get small codes for business scenarios where you need a very large number of codes. T he small program code generated through this interface is permanently valid and has no limit on the number. For more information, see Get QR codes.
How to call:
POST https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=ACCESS_TOKEN
Property | Type | The default | Required | Description |
---|---|---|---|---|
access_token | string | Is | The interface calls the credentials | |
scene | string | Is |
Up to 32 visible characters, support only numbers, case english and some
!#$&'()*+,/:;=?@-._~
as legitimate characters
%
(Chinese cannot be processed
urlencode
because % is not supported, please use a different encoding method)
|
|
page | string | Home | Whether |
Must be a page that already exists for a small program (otherwise errors are reported), such as
pages/index/index
do not fill
/
do not carry parameters (parameters should be placed in the scene field), if you do not fill in this field, the default skip main page
|
width | number | 430 | Whether | The width of the QR code in px, minimum 280px, maximum 1280px |
auto_color | boolean | false | no | Automatically configure the line color, if the color is still black, then the main tone is not recommended, the default FALSE |
line_color | Object | {"r":0,"g":0,"b":0} | no |
Auto_Color takes effect for false, using the RGB setting color, for example
{"r":"xxx","g":"xxx","b":"xxx"}
Ten etiquette
|
is_hyaline | boolean | false | Whether | If a transparent base color is required, a small program with a transparent base color is generated when true |
The returned picture is Buffer
Json
Property | Type | Description |
---|---|---|
errcode | number | Error code |
errmsg | string | The error message |
The legal value of errcode
Value | Description | The lowest version |
---|---|---|
45009 | Call minute frequency is limited (currently 5000 times per minute, adjusted), if a large number of small codes are required, it is recommended to pre-build. | |
41030 | The page that was passed does not exist, or the small program is not published |
If the call is successful, the picture binary content is returned directly, and if the request fails, the data in JSON format is returned.
The value of the scene field is passed as a query parameter to the small program/game. After the user scans the code into the small program/game, the developer can get the scene value in the QR code and then do the processing logic.
The debugging phase can use the conditions of the development tool to compile the custom parameter scene=xxxx for simulation, and the parameter value of the scene when the development tool simulates requires encodeURIComponent
Small program
Page({
onLoad (query) {
// scene 需要使用 decodeURIComponent 才能获取到生成二维码时传入的 scene
const scene = decodeURIComponent(query.scene)
}
})
Small games
// 在首次启动时通过 wx.getLaunchOptionsSync 接口获取
const {query} = wx.getLaunchOptionsSync()
const scene = decodeURIComponent(query.scene)
// 或者在 wx.onShow 事件中获取
wx.onShow(function ({query}) {
// scene 需要使用 decodeURIComponent 才能获取到生成二维码时传入的 scene
const scene = decodeURIComponent(query.scene)
})
Request
{
"scene": "a=1"
}
Return
{
"errcode": 0,
"errmsg": "ok",
"contentType": "image/jpeg",
"buffer": Buffer
}
Cloud call is the ability provided by the small program Cloud Development to call WeChat open interfaces in cloud functions and need to be used in cloud functions via wx-server-sdk.
openapi.wxacode.getUnlimited
Permissions for the wxacode.getUnlimited API need to be configured in config.json, details
Property | Type | The default | Required | Description |
---|---|---|---|---|
scene | string | Is |
Up to 32 visible characters, support only numbers, case english and some
!#$&'()*+,/:;=?@-._~
as legitimate characters
%
(Chinese cannot be processed
urlencode
because % is not supported, please use a different encoding method)
|
|
page | string | Home | Whether |
Must be a page that already exists for a small program (otherwise errors are reported), such as
pages/index/index
do not fill
/
do not carry parameters (parameters should be placed in the scene field), if you do not fill in this field, the default skip main page
|
width | number | 430 | Whether | The width of the QR code in px, minimum 280px, maximum 1280px |
autoColor | boolean | false | Whether | The line color is automatically configured, and if the color is still black, the main tone is not recommended, the default false |
lineColor | Object | {"r":0,"g":0,"b":0} | Whether |
auto_color is false, use rgb to set colors such as
{"r":"xxx","g":"xxx","b":"xxx"}
for a hex
|
isHyaline | boolean | false | Whether | If a transparent base color is required, a small program with a transparent base color is generated when true |
An object that contains binary data and its data type
Property | Type | Description |
---|---|---|
contentType | String | Data Type (MIME Type) |
buffer | Buffer | Data Buffer |
Json
Property | Type | Description |
---|---|---|
errCode | number | Error code |
errMsg | string | The error message |
The legal value of errCode
Value | Description | The lowest version |
---|
Request
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.wxacode.getUnlimited({
scene: 'a=1'
})
return result
} catch (err) {
return err
}
}
Return
{
"errcode": 0,
"errmsg": "ok",
"contentType": "image/jpeg",
"buffer": Buffer
}