创新互联小程序教程:微信小程序订阅消息·getCategory
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. | 类目列表 | 
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
  }
}
本文题目:创新互联小程序教程:微信小程序订阅消息·getCategory
浏览地址:http://jxruijie.cn/article/dhehjgs.html


 
                