# 设置频道页面皮肤接口

### 接口URL

```
https://api.polyv.net/live/v3/channel/theme/set
```

### 接口说明

```
1、接口用于设置频道页面皮肤接口
2、接口支持https
```

### 返回结果格式

```
JSON
```

### 请求方式

```
POST
```

### 请求参数

| 参数名               | 必选 | 类型     | 说明                                                                                                                                                                                                        |
| ----------------- | -- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| appId             | 是  | string | 从API设置中获取，在直播系统登记的appId                                                                                                                                                                                   |
| timestamp         | 是  | long   | 当前13位毫秒级时间戳，3分钟内有效                                                                                                                                                                                        |
| sign              | 是  | String | 签名，为32位大写的MD5值,`生成签名的appSecret密钥作为通信数据安全的关键信息，严禁保存在客户端直接使用，所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据`【详见[签名生成规则](https://git.polyv.net/help-center/document-center/-/blob/master/live/api/buildSign/README.md)】 |
| channelId         | 是  | int    | 频道号                                                                                                                                                                                                       |
| watchLayout       | 否  | string | 观看布局，直播助手（纯视频）场景下取值：normal 常规直播 portrait 竖屏直播 ，云课堂场景：video 视频为主 ppt 文档为主                                                                                                                                  |
| mobileWatchLayout | 否  | string | 移动端观看布局，直播助手（纯视频）场景下取值：normal 常规直播 portrait 竖屏直播 ，云课堂场景：normal 常规直播 portrait 竖屏直播                                                                                                                         |
| templateType      | 否  | string | 观看页模版，old 为旧版 new为新版                                                                                                                                                                                      |
| pageSkin          | 否  | string | 皮肤风格 ，black white blue red green                                                                                                                                                                          |

### 响应成功JSON示例：

```json
{
    "code": 200,
    "status": "success",
    "message": "",
    "data":  ""
}
```

### 响应失败JSON示例：

未输入appId

```json
{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}
```

appId不正确

```json
{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}
```

时间戳错误

```json
{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}
```

签名错误

```json
{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
```

非法频道号

```json
{
    "code": 400,
    "data": "",
    "message": "illegal channel id: 10001",
    "status": "error"
}
```

非法的参数值

```json
{
    "code": 400,
    "data": "",
    "message": "illegal param type: watchLayout",
    "status": "error"
}
```

```json
{
    "code": 400,
    "data": "",
    "message": "illegal param type: mobileWatchLayout",
    "status": "error"
}
```

### 字段说明

| 参数名     | 说明                                  |
| ------- | ----------------------------------- |
| code    | 响应代码，成功为200，失败为400，签名错误为403，异常错误500 |
| status  | 成功为success，失败为error                 |
| message | 错误时为错误提示消息                          |
| data    | 成功数据                                |

### Java请求示例

```java
public static void test() {
        String url = "https://api.polyv.net/live/v3/channel/theme/set";
        // 用户对应的appId和加密串
        String appId = "xxxxxxxxx";
        String appSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
        int channelId = 10001;
        Map<String, String> params = new HashMap<>();
        params.put("channelId", channelId);
		params.put("watchLayout", "normal");
        PolyvTool.setLiveSign(params, appId, appSecret);
        // 调用Polyv的httpClient工具类发送请求
        String content = HttpClientUtil.getInstance()
                .sendHttpPost(url + "?" + PolyvTool.mapJoinNotEncode(params));
        System.out.println(content);
    }
```
