# Get QR Code

The QR Code of the Mini Game has the same style and access method as the Mini Program. Through the background interface, the QR Code of the Mini Game can be obtained, and the Mini Game can be accessed directly via scanning the QR code. At present, Weixin supports two kinds of QR Codes, Mini Program Code (left), and Mini Program QR Code (right) as follows:

# Get Mini Program Code

We recommend generating and using Mini Program Code, which has better recognition. Currently, there are two interfaces that can generate Mini Program Code. Developers can choose the appropriate interface according to their needs.

Interface A: Applicable to business scenarios with a small number of codes required Interface Address:

https://api.weixin.qq.com/wxa/getwxacode?access_token=ACCESS_TOKEN

Get access_token See document for details

POST Parameters Description

Parameter Type Defaults Description
path String Can't be empty, maximum length is 128 bytes. Mini Game does not have the concept of page, so the query is passed to this parameter as ?a=b&c=d
width Int 430 Width of QR Code
auto_color Bool false Automatically configure the line color, if the color is still black, it is not recommended to configure the main color
line_color Object {"r":"0","g":"0","b":"0"} Effective when auth_color is false, and use rgb to set the color, such as {"r":"xxx" ,"g":"xxx","b":"xxx"}

Note: The Mini Program Code generated through this interface is permanently valid. The quantity limit is as stated at the end of this document. Please use it with caution. After the user scans the code to enter the Mini Program, it will directly enter the page corresponding to the path.

Interface B: For service scenarios that require a very large number of codes or only temporary use

Interface Address:

https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=ACCESS_TOKEN

Get access_token See document for details

POST Parameters Description

Parameter Type Defaults Description
scene String Maximum 32 visible characters, only numbers, uppercase and lowercase English and some special characters: !#$&'()*+,/:;=?@-._~ are supported, please encode other characters to legal characters by yourself (Chinese cannot be processed with urlencode because % is not supported, please use another encoding method)
width Int 430 Width of QR Code
auto_color Bool false Automatically configure the line color, if the color is still black, it is not recommended to configure the main color
line_color Object {"r":"0","g":"0","b":"0"} Effective when auto_color is false, and use rgb to set the color, such as {"r":"xxx" ,"g":"xxx","b":"xxx"}

Note: The Mini Program Code generated through this interface is permanently valid and the quantity is temporarily unlimited. After the user scans the code to enter the Mini Program, the developer needs to get the value of the scene field in the code on the corresponding page and then process the logic. Get the value of the scene field in the QR code via following code. During debugging stage, the developer can use the conditions of the Devtools to compile the custom parameters scene=xxxx for simulation, the scene parameter values need to be urlencoded

wx.onShow(function (option) {
    var scene = decodeURIComponent(option.query.scene)
})

# Get Mini Program QR Code

Interface C: applicable to business scenarios with a small number of codes required

Interface Address:

https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=ACCESS_TOKEN

Get access_token See document for details

POST Parameters Description

Parameter Type Defaults Description
path String Can't be empty, maximum length is 128 bytes. The Mini Game does not have the concept of page, so only the query part of path is required, such as ?a=b&c=d
width Int 430 Width of QR Code

Note: The Mini Program QR Code generated through this interface is permanently valid. The quantity limit is as stated at the end of this document. Please use it with caution.

Example:

{
    "path": "?query=1", 
    "width": 430
}

# Bug & Tip

  1. tip: Through this interface, only the QR code of the released Mini Program can be generated.
  2. tip: You can generate a development version of a QR code with parameters in the Developer Tools preview.
  3. tip: Interface A plus interface C, the total number of generated codes is limited to 100,000, please call with caution.
  4. tip: The POST parameter needs to be converted to a json string. Form form submission is not supported.
  5. tip: The auto_color line_color parameter is only valid for Mini Program Code.
点击咨询小助手