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
This interface provides an API for bar/QR code identification based on small programs.
How to call:
POST https://api.weixin.qq.com/cv/img/qrcode?img_url=ENCODE_URL&access_token=ACCESS_TOCKEN
Property | Type | The default | Required | Description |
---|---|---|---|---|
access_token | string | Is | The interface calls the credentials | |
img_url | string | Is | To detect the picture url, pass this without passing the img parameter. | |
Img | FormData | Is | Form-data media file identification, there is fileame, filelength, content-type and other information, pass this without passing img_url. |
The returned JSON packet
Property | Type | Description |
---|---|---|
errcode | string | Error code |
errmsg | string | The error message |
Image caption File size limit: less than 2M
QR Code Description Supports the identification of barcodes, QR codes, DataMatrix, and PDF417. The QR code, DataMatrix returns the location coordinates, and the barcode and PDF417 do not return the location coordinates.
Example 1:
curl https://api.weixin.qq.com/cv/img/qrcode?img_url=ENCODE_URL&access_token=ACCESS_TOCKEN
Example 2:
curl -F 'img=@test.jpg' 'https://api.weixin.qq.com/cv/img/qrcode?access_token=ACCESS_TOCKEN'
{
"errcode": 0,
"errmsg": "ok",
"code_results": [
{
"type_name": "QR_CODE",
"data": "http://www.qq.com",
"pos": {
"left_top": {
"x": 585,
"y": 378
},
"right_top": {
"x": 828,
"y": 378
},
"right_bottom": {
"x": 828,
"y": 618
},
"left_bottom": {
"x": 585,
"y": 618
}
}
},
{
"type_name": "QR_CODE",
"data": "https://mp.weixin.qq.com",
"pos": {
"left_top": {
"x": 185,
"y": 142
},
"right_top": {
"x": 396,
"y": 142
},
"right_bottom": {
"x": 396,
"y": 353
},
"left_bottom": {
"x": 185,
"y": 353
}
}
},
{
"type_name": "EAN_13",
"data": "5906789678957"
},
{
"type_name": "CODE_128",
"data": "50090500019191"
}
],
"img_size": {
"w": 1000,
"h": 900
}
}
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.img.scanQRCode
Permissions for the img.scanQRCode API need to be configured in config.json, details
Property | Type | The default | Required | Description |
---|---|---|---|---|
imgUrl | string | Is | To detect the picture url, pass this without passing the img parameter. | |
Img | FormData | Is | Form-data media file identification, there is fileame, filelength, content-type and other information, pass this without passing img_url. |
The structure of img
Property | Type | The default | Required | Description |
---|---|---|---|---|
contentType | string | Is | Data type, incoming MIME Type | |
value | Buffer | Is | File Buffer |
The returned JSON packet
Property | Type | Description |
---|---|---|
errCode | string | Error code |
errMsg | string | The error message |
The exception thrown
Property | Type | Description |
---|---|---|
errCode | string | Error code |
errMsg | string | The error message |
The legal value of errCode
Value | Description | The lowest version |
---|
Image caption File size limit: less than 2M
QR Code Description Supports the identification of barcodes, QR codes, DataMatrix, and PDF417. The QR code, DataMatrix returns the location coordinates, and the barcode and PDF417 do not return the location coordinates.
{
"errcode": 0,
"errmsg": "ok",
"code_results": [
{
"type_name": "QR_CODE",
"data": "http://www.qq.com",
"pos": {
"left_top": {
"x": 585,
"y": 378
},
"right_top": {
"x": 828,
"y": 378
},
"right_bottom": {
"x": 828,
"y": 618
},
"left_bottom": {
"x": 585,
"y": 618
}
}
},
{
"type_name": "QR_CODE",
"data": "https://mp.weixin.qq.com",
"pos": {
"left_top": {
"x": 185,
"y": 142
},
"right_top": {
"x": 396,
"y": 142
},
"right_bottom": {
"x": 396,
"y": 353
},
"left_bottom": {
"x": 185,
"y": 353
}
}
},
{
"type_name": "EAN_13",
"data": "5906789678957"
},
{
"type_name": "CODE_128",
"data": "50090500019191"
}
],
"img_size": {
"w": 1000,
"h": 900
}
}