Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat Apple Search ImageSearch


May 20, 2021 WeChat Mini Program Development Document


Table of contents


search.imageSearch

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:

  • HTTPS call
  • Cloud calls

HTTPS call

The request address

POST https://api.weixin.qq.com/wxa/imagesearch?access_token=TOKEN

Request parameters

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

Returns a value

Object

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

An example of a request

curl -F 'img=@test.jpg' "https://api.weixin.qq.com/wxa/imagesearch?access_token=TOKEN"

Example of a cloud call request

// javascript
// cloud = require('wx-server-sdk')
// ...
// 方法返回 Promise
cloud.openapi.search.imageSearch({
  img: {
     contentType: 'image/png',
     value: Buffer
  }
})

Cloud calls

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.

The interface method

openapi.search.imageSearch
The permissions to the search.imageSearch API need to be configured in config.json, details

Request parameters

Property Type The default Required Description
Img Array.<FormData> Is Media file identification in form-data, with fileame, filelength, content-type and other information

Returns a value

Object

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

Abnormal

Object

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