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
Get the class of the small program account number
How to call:
GET https://api.weixin.qq.com/wxaapi/newtmpl/getcategory?access_token=ACCESS_TOKEN
Property | Type | The default | Required | Description |
---|---|---|---|---|
access_token | string | Is | The interface calls the credentials |
Property | Type | Description |
---|---|---|
errcode | number | Error code |
errmsg | string | The error message |
data | Array.<Object> | The list of classes |
The structure of the data
Property | Type | Description |
---|---|---|
Id | number | Class id, required when querying public library templates |
name | string | The name of Chinese purpose |
{
"errcode": 0,
"errmsg": "ok",
"data": [
{
"id": 616,
"name": "公交"
}
]
}
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.subscribeMessage.getCategory
Permissions for the subscribeMessage.getCategory API need to be configured in config.json, details
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.subscribeMessage.getCategory({})
return result
} catch (err) {
return err
}
}
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.subscribeMessage.getCategory({
errcode: 0,
errmsg: 'ok',
data: [
{
id: 616,
name: '公交'
}
]
})
return result
} catch (err) {
return err
}
}