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 the small program QR code for business scenarios where the number of codes required is small. The small program code generated through this interface is permanently valid and has a limit on the number, see Get QR code.
How to call:
POST https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=ACCESS_TOKEN
Property | Type | The default | Required | Description |
---|---|---|---|---|
access_token | string | Is | The interface calls the credentials | |
path | string | Is |
The path to the small program page entered by the broom, with a maximum length of 128 bytes, cannot be empty, and for small games, only the query section can be passed in to achieve a parameter effect, such as: incoming "?foo-bar", which can be obtained from the query parameter
wx.getLaunchOptionsSync
interface to the
{foo:"bar"}
|
|
width | number | 430 | Whether | The width of the QR code in px. Min 280px, max 1280px |
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 |
---|---|---|
45029 | The sum of the generated yards reaches the maximum number limit |
If the call is successful, the picture binary content is returned directly, and if the request fails, the data in JSON format is returned.
Request
{
"path":"page/index/index",
"width":430
}
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.createQRCode
Permissions for the wxacode.createQRCode API need to be configured in config.json, details
Property | Type | The default | Required | Description |
---|---|---|---|---|
path | string | Is |
The path to the small program page entered by the broom, with a maximum length of 128 bytes, cannot be empty, and for small games, only the query section can be passed in to achieve a parameter effect, such as: incoming "?foo-bar", which can be obtained from the query parameter
wx.getLaunchOptionsSync
interface to the
{foo:"bar"}
|
|
width | number | 430 | Whether | The width of the QR code in px. Min 280px, max 1280px |
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.createQRCode({
path: 'page/index/index',
width: 430
})
return result
} catch (err) {
return err
}
}
Return
{
"errcode": 0,
"errmsg": "ok",
"contentType": "image/jpeg",
"buffer": Buffer
}