pushGoods.md 3.17 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
小程序直播 /直播间管理 /推送商品

# 推送商品

> 接口应在服务器端调用,详细说明参见[服务端API](https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/backend-api.html)。

> 本接口支持[云调用](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html)。需开发者工具版本 >= `1.02.1904090`(最新[稳定版下载](https://developers.weixin.qq.com/miniprogram/dev/devtools/stable.html)),`wx-server-sdk` >= `0.4.0`

## 接口说明

### 接口英文名

pushGoods

### 功能描述

该接口用于推送商品到直播间。

### 注意事项

调用额度:10000次/一天。

## 调用方式

### HTTPS 调用

```text
POST https://api.weixin.qq.com/wxaapi/broadcast/goods/push?access_token=ACCESS_TOKEN 
```

### 云调用

- 出入参和 HTTPS 调用相同,调用方式可查看[云调用说明文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html)
- 接口方法为: openapi.liveBroadcast.goodsPush

### 第三方调用

- 调用方式以及出入参和 HTTPS 相同,仅是调用的 token 不同
- 该接口所属的权限集 id 为:52
- 服务商获得其中之一权限集授权后,可通过使用[authorizer_access_token](https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/token/api_authorizer_token.html)代商家进行调用

### 请求参数含义

| **参数** | **类型** | **必填** | **说明** |
| :------- | :------- | :------- | :------- |
| roomId   | Number   | 是       | 房间ID   |
| goodsId  | Number   | 是       | 商品ID   |

### 返回参数含义

| **参数** | **类型** | **说明** |
| :------- | :------- | :------- |
| errcode  | number   | 返回码   |

## 调用示例

> 示例说明: HTTPS请求示例

### 请求数据示例

```json
{
    "roomId": 6474,
    "goodsId" : 1
} 
```

### 返回数据示例

```json
{
    "errcode": 0,
    "errmsg": "ok"
} 
```

### 错误码

| 错误码 | 错误码取值                                              | 解决方案                                                     |
| :----- | :------------------------------------------------------ | :----------------------------------------------------------- |
| 40001  | invalid credential access_token isinvalid or not latest | 获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口 |
| 300023 | 房间状态 拦截(当前房间状态不允许此操作)               |                                                              |
| 300024 | 商品不存在                                              |                                                              |
| 300047 | 已有商品正在推送,请稍后再试                            |                                                              |
| 300052 | 已下架的商品无法推送                                    |                                                              |
| 300053 | 直播间未添加此商品                                      |                                                              |