获取关键词列表

获取关键词列表

调试工具

接口应在服务器端调用,详细说明参见服务端API

本接口支持云调用。需开发者工具版本 >= 1.02.1904090(最新稳定版下载),wx-server-sdk >= 0.4.0

接口说明

接口英文名

getPubTemplateKeyWordsById

功能描述

该接口用于获取模板标题下的关键词列表。

调用方式

HTTPS 调用

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

云调用

  • 出入参和HTTPS调用相同,调用方式可查看云调用说明文档
  • 接口方法为: openapi.subscribeMessage.getPubTemplateKeyWordsById

第三方调用

  • 调用方式以及出入参和HTTPS相同,仅是调用的token不同
  • 该接口所属的权限集id为:18、89
  • 服务商获得其中之一权限集授权后,可通过使用authorizer_access_token代商家进行调用

请求参数

属性 类型 必填 说明
access_token string 接口调用凭证,该参数为 URL 参数,非 Body 参数。使用access_token或者authorizer_access_token
tid string 模板标题 id,可通过接口获取

返回参数

属性 类型 说明
errcode number 错误码
errmsg string 错误信息
count number 模版标题列表总数
data array 关键词列表
属性类型说明kidnumber关键词 id,选用模板时需要namestring关键词内容examplestring关键词内容对应的示例rulestring参数类型

调用示例

示例说明: HTTPS请求示例

请求数据示例

https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatekeywords?access_token=ACCESS_TOKEN&tid=99 

返回数据示例

{
   "errcode": 0,
   "errmsg": "ok",
   "data": [
       {
           "kid": 1,
           "name": "物品名称",
           "example": "名称",
           "rule": "thing"
       }
   ]
} 

示例说明: 云函数调用示例

请求数据示例

const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV,
})
exports.main = async (event, context) => {
  try {
    const result = await cloud.openapi.subscribeMessage.getPubTemplateKeyWordsById({
        "tid": ''
      })
    return result
  } catch (err) {
    return err
  }
} 

返回数据示例

{
  "errCode": 0,
  "errMsg": "openapi.subscribeMessage.getPubTemplateKeyWordsById:ok",
  "data": [
    {
      "kid": 1,
      "name": "物品名称",
      "example": "名称",
      "rule": "thing"
    }
  ]
} 

错误码

错误码 错误描述 解决方案
40001 invalid credential access_token isinvalid or not latest 获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口
200002 入参错误
200014 模板 tid 参数错误
posted on 2025-01-14 08:42  AtlasLapetos  阅读(11)  评论(0)    收藏  举报