May 20, 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 on-site search for goods picture search capability based on small programs
How to call:
POST https://api.weixin.qq.com/wxa/imagesearch?access_token=TOKEN
Property | Type | The default | Required | Description |
---|---|---|---|---|
access_token | string | Is | The interface calls the credentials | |
Img | Array.<FormData> | Is | Media file identification in form-data, with fileame, filelength, content-type and other information |
The returned JSON packet
Property | Type | Description |
---|---|---|
errcode | string | Error code |
errmsg | string | The error message |
items | Array.<Object> | A list of search results |
The legal value of errcode
Value | Description | The lowest version |
---|---|---|
0 | The request was successful | |
-1 | The system is busy, so please try again later | |
41005 | Failed to get picture data, please check the picture data format |
The structure of the items
Property | Type | Description |
---|---|---|
title | string | The title of the small program merchandise page |
img_url | string | Small program merchandise page main figure url |
price | string | Small program merchandise page price |
path | string | Small program merchandise page address |
curl -F 'img=@test.jpg' "https://api.weixin.qq.com/wxa/imagesearch?access_token=TOKEN"
// javascript
// cloud = require('wx-server-sdk')
// ...
// 方法返回 Promise
cloud.openapi.search.imageSearch({
img: {
contentType: 'image/png',
value: Buffer
}
})
Cloud calling is the ability provided by the small program Cloud Development to invoke WeChat's open interface in cloud functions and needs to be used in cloud functions via wx-server-sdk.
openapi.search.imageSearch
The permissions to the search.imageSearch API need to be configured in config.json, details
Property | Type | The default | Required | Description |
---|---|---|---|---|
Img | Array.<FormData> | Is | Media file identification in form-data, with fileame, filelength, content-type and other information |
The returned JSON packet
Property | Type | Description |
---|---|---|
errCode | string | Error code |
errMsg | string | The error message |
items | Array.<Object> | A list of search results |
The legal value of errCode
Value | Description | The lowest version |
---|---|---|
0 | Success |
The structure of the items
Property | Type | Description |
---|---|---|
title | string | The title of the small program merchandise page |
imgUrl | string | Small program merchandise page main figure url |
price | string | Small program merchandise page price |
path | string | Small program merchandise page address |
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 |
---|---|---|
-1 | The system is busy, so please try again later | |
41005 | Failed to get picture data, please check the picture data format |