本文整理自网络,侵删。
subscribeMessage.getCategory
本接口应在服务器端调用,详细说明参见服务端API。 本接口支持云调用。需开发者工具版本 >= 1.02.1904090(最新稳定版下载)wx-server-sdk >= 0.4.0
获取小程序账号的类目
调用方式:
- HTTPS 调用
- 云调用
HTTPS 调用
请求地址
GET https://api.weixin.qq.com/wxaapi/newtmpl/getcategory?access_token=ACCESS_TOKEN
请求参数
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
access_token | string | 是 | 接口调用凭证 |
返回的 JSON 数据包
属性 | 类型 | 说明 |
---|---|---|
errcode | number | 错误码 |
errmsg | string | 错误信息 |
data | Array.<Object> | 类目列表 |
data 的结构
属性 | 类型 | 说明 |
---|---|---|
id | number | 类目id,查询公共库模版时需要 |
name | string | 类目的中文名 |
响应示例
{
"errcode": 0,
"errmsg": "ok",
"data": [
{
"id": 616,
"name": "公交"
}
]
}
云调用
云调用是小程序·云开发提供的在云函数中调用微信开放接口的能力,需要在云函数中通过 wx-server-sdk 使用。接口方法
openapi.subscribeMessage.getCategory
需在 config.json 中配置 subscribeMessage.getCategory API 的权限,详情
请求示例
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.subscribeMessage.getCategory({})
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.getCategory({
errcode: 0,
errmsg: 'ok',
data: [
{
id: 616,
name: '公交'
}
]
})
return result
} catch (err) {
return err
}
}
标签:微信小程序
相关阅读 >>
微信小程序api 用户信息 wx.getuserinfo(object)
更多相关阅读请进入《微信小程序》频道 >>

Vue.js 设计与实现 基于Vue.js 3 深入解析Vue.js 设计细节
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者