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

WeChat Apple Subscribe to Message GetPubTemplateItleList


May 20, 2021 WeChat Mini Program Development Document


Table of contents


subscribeMessage.getPubTemplateTitleList

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:

  • HTTPS call
  • Cloud calls

HTTPS call

Request address

GET https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatetitles?access_token=ACCESS_TOKEN

Request parameters

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.

return value

Object

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

Request example

{
  "ids": "2,616",
  "start": 0,
  "limit": 1
}

An example response

{
   "errcode": 0,
   "errmsg": "ok",
   "count": 55,
   "data": [
       {
           "tid": 99,
           "title": "付款成功通知",
           "type": 2,
           "categoryId": "616"
       }
   ]
}

Cloud calls

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.

The interface method

openapi.subscribeMessage.getPubTemplateTitleList
Permissions for the subscribeMessage.getPubTemplateTitleList API need to be configured in config.json, details

Request parameters

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.

Returns a value

Object

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

Abnormal

Object

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

An example of a request

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
  }
}

An example of a request

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
  }
}

An example response

{
  "errCode": 0,
  "errMsg": "openapi.subscribeMessage.getPubTemplateTitleList:ok",
  "count": 55,
  "data": [
    {
      "tid": 99,
      "title": "付款成功通知",
      "type": 2,
      "categoryId": "616"
    }
  ]
}