Generate Mini Program Code Interface

Generate mini program code (QR code), used to quickly enter the specified page in the WeChat mini program, supporting the carrying of scene parameters.

Points to note

  • The API uses the POST method and requires data to be submitted in application/ format
  • Need to provide the applet path and scene parameters
  • The generated applet code can be used for sharing and promotion
  • Some parameters have length and format restrictions
  • Need to configure relevant applet information for normal use

Request address

{域名地址}/api/weapp/qrcode

Description:{域名地址}Replace it with your domain name, such ashttps://en.anqicms.com/api/weapp/qrcode

Request Syntax

POST {域名地址}/api/weapp/qrcode
Content-Type: application/json

Request Headers

This interface also involves common request headers. For more information, please refer toCommon Request Headers (Common Request Headers).

Request parameters

Field name Type Required Description
path string Is Mini-program page path, such as/pages/index/index
scene string Is Scene parameters, used to pass custom data, up to 32 characters in length

Response header

This interface only involves common response headers. For more information, please refer toCommon Request Headers (Common Request Headers).

Return parameters

Field name Type Description
code int Error code
msg string Error description
data string Mini-program code image URL address generated

Usage Example

Request example

POST /api/weapp/qrcode HTTP/1.1
Host: www.anqicms.com
Content-Type: application/json

{
  "path": "/pages/product/detail",
  "scene": "product_id=123"
}

Response Example

{
  "code": 0,
  "msg": "",
  "data": "https://en.anqicms.com/uploads/qrcode/2023/12/123456789.jpg"
}

Error request example

POST /api/weapp/qrcode HTTP/1.1
Host: www.anqicms.com
Content-Type: application/json

{
  "path": "",
  "scene": "product_id=123"
}

Example of error response

{
  "code": -1,
  "msg": "path参数不能为空"
}

error code

Error code Description
0 OK
-1 Error, the reason is indicated in msg
1001 Not logged in
1002 Not authorized
200 API request OK
3001 Path parameter cannot be empty
3002 Error in scene parameter format