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 program codes for business scenarios where fewer codes are required. 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/wxa/getwxacode?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 |
auto_color | boolean | false | Whether | Line color is automatically configured, and if the color is still black, the main tone is not recommended |
line_color | 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
|
is_hyaline | boolean | false | Whether | Whether a transparent base color is required, a small program code for a transparent base color is generated when true |
Returns Picture 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.get
Permissions for the wxacode.get 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 |
autoColor | boolean | false | Whether | Line color is automatically configured, and if the color is still black, the main tone is not recommended |
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 | Whether a transparent base color is required, a small program code for 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.get({
path: 'page/index/index',
width: 430
})
return result
} catch (err) {
return err
}
}
Return
{
"errcode": 0,
"errmsg": "ok",
"contentType": "image/jpeg",
"buffer": Buffer
}