微信小程序 訂閱消息·getPubTemplateTitleList

2022-05-12 15:30 更新

subscribeMessage.getPubTemplateTitleList

本接口應(yīng)在服務(wù)器端調(diào)用,詳細說明參見服務(wù)端API。
本接口支持云調(diào)用。需開發(fā)者工具版本 >= 1.02.1904090(最新穩(wěn)定版下載
wx-server-sdk >= 0.4.0

獲取帳號所屬類目下的公共模板標題

調(diào)用方式:

  • HTTPS 調(diào)用
  • 云調(diào)用

HTTPS 調(diào)用

請求地址

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

請求參數(shù)

屬性 類型 默認值 必填 說明
access_token string 接口調(diào)用憑證
ids string 類目 id,多個用逗號隔開
start number 用于分頁,表示從 start 開始。從 0 開始計數(shù)。
limit number 用于分頁,表示拉取 limit 條記錄。最大為 30。

返回值

Object

返回的 JSON 數(shù)據(jù)包

屬性 類型 說明
errcode number 錯誤碼
errmsg string 錯誤信息
count number 模版標題列表總數(shù)
data Array.<Object> 模板標題列表

errcode 的合法值

說明 最低版本
200016 start 參數(shù)錯誤
200017 limit 參數(shù)錯誤
200018 類目 ids 缺失
200019 類目 ids 不合法

data 的結(jié)構(gòu)

屬性 類型 說明
tid number 模版標題 id
title string 模版標題
type number 模版類型,2 為一次性訂閱,3 為長期訂閱
categoryId number 模版所屬類目 id

請求示例

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

響應(yīng)示例

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

云調(diào)用

云調(diào)用是小程序·云開發(fā)提供的在云函數(shù)中調(diào)用微信開放接口的能力,需要在云函數(shù)中通過 wx-server-sdk 使用。

接口方法

openapi.subscribeMessage.getPubTemplateTitleList
需在 config.json 中配置 subscribeMessage.getPubTemplateTitleList API 的權(quán)限,詳情

請求參數(shù)

屬性 類型 默認值 必填 說明
ids string 類目 id,多個用逗號隔開
start number 用于分頁,表示從 start 開始。從 0 開始計數(shù)。
limit number 用于分頁,表示拉取 limit 條記錄。最大為 30。

返回值

Object

返回的 JSON 數(shù)據(jù)包

屬性 類型 說明
errCode number 錯誤碼
errMsg string 錯誤信息
count number 模版標題列表總數(shù)
data Array.<Object> 模板標題列表

errCode 的合法值

說明 最低版本
0 成功

data 的結(jié)構(gòu)

屬性 類型 說明
tid number 模版標題 id
title string 模版標題
type number 模版類型,2 為一次性訂閱,3 為長期訂閱
categoryId number 模版所屬類目 id

異常

Object

拋出的異常

屬性 類型 說明
errCode number 錯誤碼
errMsg string 錯誤信息

errCode 的合法值

說明 最低版本
200016 start 參數(shù)錯誤
200017 limit 參數(shù)錯誤
200018 類目 ids 缺失
200019 類目 ids 不合法

請求示例

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

響應(yīng)示例

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


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號