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 public template title under the class to which the account belongs
How to call:
GET https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatetitles?access_token=ACCESS_TOKEN
Attributes | type | Defaults | Required | illustrate |
---|---|---|---|---|
access_token | string | Yes | Interface call credential | |
ids | string | Yes | Category ID, multiple comma separated | |
start | number | Yes | Used for paging, indicating that starting from START.Count the count from 0. | |
limit | number | Yes | Used for paging, indicating that pulls the LIMIT strip record.Maximum 30. |
Returned JSON packet
Attributes | type | illustrate |
---|---|---|
errcode | number | error code |
errmsg | string | Error message |
count | number | Total number of template title list |
data | Array.<Object> | Template title list |
Errcode's legitimate value
value | illustrate | Minimum version |
---|---|---|
200016 | START parameter error | |
200017 | LIMIT parameter error | |
200018 | Class IDS missing | |
200019 | Class IDS is not legal |
DATA structure
Attributes | type | illustrate |
---|---|---|
tid | number | Template title ID |
title | string | Template title |
type | number | Type of template, 2 is a disposable subscription, 3 for long-term subscriptions |
categoryId | number | Template class ID |
{
"ids": "2,616",
"start": 0,
"limit": 1
}
{
"errcode": 0,
"errmsg": "ok",
"count": 55,
"data": [
{
"tid": 99,
"title": "付款成功通知",
"type": 2,
"categoryId": "616"
}
]
}
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.subscribeMessage.getPubTemplateTitleList
Permissions for the subscribeMessage.getPubTemplateTitleList API need to be configured in config.json, details
Property | Type | The default | Required | Description |
---|---|---|---|---|
Ids | string | Is | Class id, multiple separated by commas | |
start | number | Is | Used to peddle, indicating that start begins. Count from 0. | |
limit | number | Is | Used for pedding, which means pulling the limit record. The maximum is 30. |
The returned JSON packet
Property | Type | Description |
---|---|---|
errCode | number | Error code |
errMsg | string | The error message |
count | number | The total number of template title lists |
data | Array.<Object> | The list of template titles |
The legal value of errCode
Value | Description | The lowest version |
---|---|---|
0 | Success |
The structure of the data
Property | Type | Description |
---|---|---|
tid | number | Template title id |
title | string | The template title |
type | number | Template type, 2 is a one-time subscription and 3 is a long-term subscription |
categoryId | number | The class id to which the template belongs |
The exception thrown
Property | Type | Description |
---|---|---|
errCode | number | Error code |
errMsg | string | The error message |
The legal value of errCode
Value | Description | The lowest version |
---|---|---|
200016 | The start argument is wrong | |
200017 | The limit parameter is wrong | |
200018 | Class ids is missing | |
200019 | Class ids is illegal |
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.subscribeMessage.getPubTemplateTitleList({
ids: '',
start: '',
limit: ''
})
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.getPubTemplateTitleList({
ids: '2,616',
start: 0,
limit: 1
})
return result
} catch (err) {
return err
}
}
{
"errCode": 0,
"errMsg": "openapi.subscribeMessage.getPubTemplateTitleList:ok",
"count": 55,
"data": [
{
"tid": 99,
"title": "付款成功通知",
"type": 2,
"categoryId": "616"
}
]
}