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 a list of keywords under the template title
How to call:
GET https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatekeywords?access_token=ACCESS_TOKEN
Property | Type | The default | Required | Description |
---|---|---|---|---|
access_token | string | Is | The interface calls the credentials | |
tid | string | Is | Template title id, available via interface |
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> | A list of keywords |
The structure of the data
Property | Type | Description |
---|---|---|
kid | number | Keywords id, when choosing a template |
name | string | Keywords content |
example | string | An example of a keyword content |
rule | string | The type of argument |
{
"tid": "99"
}
{
"errcode": 0,
"errmsg": "ok",
"data": [
{
"kid": 1,
"name": "物品名称",
"example": "名称",
"rule": "thing"
}
]
}
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.getPubTemplateKeyWordsById
Permissions for the subscribeMessage.getPubTemplateKeyWordsById API need to be configured in config.json, details
Property | Type | The default | Required | Description |
---|---|---|---|---|
tid | string | Is | Template title id, available via interface |
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> | A list of keywords |
The structure of the data
Property | Type | Description |
---|---|---|
kid | number | Keywords id, when choosing a template |
name | string | Keywords content |
example | string | An example of a keyword content |
rule | string | The type of argument |
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 |
---|
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.subscribeMessage.getPubTemplateKeyWordsById({
tid: ''
})
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.getPubTemplateKeyWordsById({
tid: '99'
})
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.getPubTemplateKeyWordsById({
errcode: 0,
errmsg: 'ok',
data: [
{
kid: 1,
name: '物品名称',
example: '名称',
rule: 'thing'
}
]
})
return result
} catch (err) {
return err
}
}