# 获取频道答题卡列表

### 接口URL

```
https://api.polyv.net/live/v3/channel/question/list
```

### 接口说明

```
1、接口用于获取频道答题卡列表
2、接口支持https
```

### 支持格式

```
JSON
```

### 请求方式

```
GET
```

### 请求参数

| 参数名       | 必选 | 类型     | 说明                                                                                                                                                                                                        |
| --------- | -- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 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 | 是  | string | 频道号                                                                                                                                                                                                       |
| startDate | 否  | string | 查询开始时间，格式yyyy-MM-dd（和endDate一起不传默认查最近七天数据）                                                                                                                                                                |
| endDate   | 否  | string | 查询的结束时间，格式：yyyy-MM-dd（和startDate一起不传默认查七天数据）                                                                                                                                                              |
| page      | 否  | int    | 页号，默认为1                                                                                                                                                                                                   |
| pageSize  | 否  | int    | 每页条数，默认为10                                                                                                                                                                                                |

### 响应成功JSON示例：

```json
// 成功
{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
    "pageNumber": 1,
    "totalItems": 7,
    "contents": [
      {
        "questionId": "",
        "name": "text",
        "type": "text",
        "channelId": 4,
        "userId": "text",
        "note": "text",
        "answer": "text",
        "lastModified": 9,
        "createdTime": 7,
        "option4": "text",
        "option5": "",
        "option2": "text",
        "option3": "text",
        "option1": "text",
        "times": 0
      }
    ],
    "startRow": 9,
    "firstPage": true,
    "nextPageNumber": 3,
    "prePageNumber": 2,
    "totalPages": 6,
    "lastPage": true,
    "endRow": 7,
    "limit": 10,
    "offset": 1
  }
}
```

### 响应失败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": ""
}
```

### 字段说明

| 参数名                            | 说明                                   |
| ------------------------------ | ------------------------------------ |
| code                           | 响应的状态码，例如：200                        |
| status                         | 响应状态                                 |
| message                        | 异常错误信息                               |
| data                           | 响应结果集                                |
| data.pageNumber                | 页数                                   |
| data.limit                     | 每页记录数                                |
| data.totalItems                | 记录总数                                 |
| data.firstPage                 | 是否为第一页，值为：true/false                 |
| data.lastPage                  | 是否为最后一页，值为：true/false                |
| data.nextPageNumber            | 下一页编号                                |
| data.prePageNumber             | 上一页编号                                |
| data.totalPages                | 总页数                                  |
| data.startRow                  | 当前页第一条记录所在列表中的位置                     |
| data.endRow                    | 当前页最后一条记录所在列表中的位置                    |
| data.contents\[0].questionId   | 题目ID                                 |
| data.contents\[0].name         | 题目名称                                 |
| data.contents\[0].type         | 题目类型("R":单选,"C"：多选，"S": 评分, "Q": 问答) |
| data.contents\[0].channelId    | 频道ID                                 |
| data.contents\[0].userId       | 用户ID                                 |
| data.contents\[0].answer       | 答案（abcd...）                          |
| data.contents\[0].note         | 答案解析                                 |
| data.contents\[0].times        | 第几场答题                                |
| data.contents\[0].option1      | 选项1                                  |
| data.contents\[0].option2      | 选项2                                  |
| data.contents\[0].option3      | 选项3                                  |
| data.contents\[0].option4      | 选项4                                  |
| data.contents\[0].option5      | 选项5                                  |
| data.contents\[0].lastModified | 更新时间                                 |
| data.contents\[0].createdTime  | 创建时间                                 |

### php请求示例

```php
<?php
//引用config.php
include 'config.php';
$params = array(
	'appId' => $appId,
	'timestamp' => $timestamp,
	'channelId' => 108888
);

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
$params['sign'] = $sign;

$url = "https://api.polyv.net/live/v3/channel/question/list?".http_build_query($params);

$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, $url);
$res = curl_exec($curl);
curl_close($curl);

echo $res;
?>
```
