| ylbtech-微信-小程序-开发文档-服务端-模板消息:templateMessage.getTemplateLibraryById |
| 1.返回顶部 |
1、
templateMessage.getTemplateLibraryById
本接口应在服务器端调用,详细说明参见服务端API。
本接口支持云调用。需开发者工具版本 >=
1.02.1904090(最新稳定版下载),wx-server-sdk>=0.4.0
获取模板库某个模板标题下关键词库
调用方式:
- HTTPS 调用
- 云调用
HTTPS 调用
请求地址
POST https://api.weixin.qq.com/cgi-bin/wxopen/template/library/get?access_token=ACCESS_TOKEN
请求参数
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| access_token | string | 是 | 接口调用凭证 | |
| id | string | 是 | 模板标题id,可通过接口获取,也可登录小程序后台查看获取 |
返回值
Object
返回的 JSON 数据包
| 属性 | 类型 | 说明 |
|---|---|---|
| errcode | number | 错误码 |
| errmsg | string | 错误信息 |
| id | string | 模板标题 id |
| title | string | 模板标题 |
| keyword_list | Array.<Object> | 关键词列表 |
keyword_list 的结构
| 属性 | 类型 | 说明 |
|---|---|---|
| keyword_id | string | 关键词 id,添加模板时需要 |
| name | string | 关键词内容 |
| example | string | 关键词内容对应的示例 |
请求数据示例
{ "id": "AT0002" }
返回数据示例
{ "errcode": 0, "errmsg": "ok", "id": "AT0002", "title": "购买成功通知", "keyword_list": [ { "keyword_id": 3, "name": "购买地点", "example": "TIT造舰厂" }, { "keyword_id": 4, "name": "购买时间", "example": "2016年6月6日" }, { "keyword_id": 5, "name": "物品名称", "example": "咖啡" } ] }
云调用
云调用是小程序·云开发提供的在云函数中调用微信开放接口的能力,需要在云函数中通过
wx-server-sdk使用。
接口方法
openapi.templateMessage.getTemplateLibraryById
需在
config.json中配置templateMessage.getTemplateLibraryByIdAPI 的权限,详情
请求参数
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| id | string | 是 | 模板标题id,可通过接口获取,也可登录小程序后台查看获取 |
返回值
Object
返回的 JSON 数据包
| 属性 | 类型 | 说明 |
|---|---|---|
| errCode | number | 错误码 |
| errMsg | string | 错误信息 |
| id | string | 模板标题 id |
| title | string | 模板标题 |
| keywordList | Array.<Object> | 关键词列表 |
keywordList 的结构
| 属性 | 类型 | 说明 |
|---|---|---|
| keywordId | string | 关键词 id,添加模板时需要 |
| name | string | 关键词内容 |
| example | string | 关键词内容对应的示例 |
异常
Object
抛出的异常
| 属性 | 类型 | 说明 |
|---|---|---|
| errCode | number | 错误码 |
| errMsg | string | 错误信息 |
errCode 的合法值
| 值 | 说明 | 最低版本 |
|---|
请求数据示例
const cloud = require(‘wx-server-sdk‘) cloud.init() exports.main = async (event, context) => { try { const result = await cloud.openapi.templateMessage.getTemplateLibraryById({ id: ‘AT0002‘ }) console.log(result) return result } catch (err) { console.log(err) return err } }
返回数据示例
{ "errCode": 0, "errMsg": "openapi.templateMessage.getTemplateLibraryById:ok", "id": "AT0002", "title": "购买成功通知", "keywordList": [ { "name": "购买地点", "example": "TIT造舰厂", "keywordId": 3 }, { "name": "购买时间", "example": "2016年6月6日", "keywordId": 4 }, { "name": "物品名称", "example": "咖啡", "keywordId": 5 } ] }
2、
| 2.返回顶部 |
| 3.返回顶部 |
| 4.返回顶部 |
| 5.返回顶部 |
1、
https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/template-message/templateMessage.getTemplateLibraryById.html
2、
| 6.返回顶部 |
| 作者:ylbtech 出处:http://ylbtech.cnblogs.com/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 |