保利威文档中心

帮助中心

分页获取答题卡的答题观众列表

更新时间:2022-09-02 18:08:07

接口URL

https://api.polyv.net/live/v3/channel/question/answer-record/list-by-page

接口说明

1、接口用于分页获取某次答题的答题观众列表
2、接口支持https

请求方式

GET

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 当前13位毫秒级时间戳,3分钟内有效
sign String 签名,为32位大写的MD5值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据【详见签名生成规则
channelId string 频道号
questionId string 题目ID,从题目列表中获取
times int 第几次的答题详情,用于同一道题发送了多次的情况,从题目列表中获取
page int 页号,默认为1
pageSize int 每页条数,默认为20

响应成功JSON示例:

// 成功
{
  "code": 200,
  "status": "success",
  "message": null,
  "data": {
    "endRow": 2,
    "contents": [
      {
        "questionId": "text",
        "costTime": 60,
        "viewerId": "",
        "submitTime": 6,
        "nickname": "",
        "submitTimeFormat": "text",
        "channelId": 3,
        "times": 1,
        "answer": "",
        "sessionId": "text",
        "costTimeFormat": "",
        "viewerAnswer": "",
        "type": "",
        "correct": "N",
        "name": ""
      }
    "firstPage": false,
    "lastPage": true,
    "limit": 0,
    "nextPageNumber": 0,
    "offset": 7,
    "pageNumber": 1,
    "pageSize": 0,
    "prePageNumber": 7,
    "startRow": 4,
    "totalItems": 0,
    "totalPages": 9,
    "nulla5af": 58983375
  }
}

响应失败JSON示例:

未输入appId

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

appId不正确

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

时间戳错误

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

签名错误

{
    "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].viewerId 观众Id
data.contents[0].nickname 观众昵称
data.contents[0].type 题目类型("R":单选,"C":多选,"S": 评分, "Q": 问答, "V": 投票)
data.contents[0].channelId 频道ID
data.contents[0].questionId 问题ID
data.contents[0].name 问题
data.contents[0].answer 问题答案
data.contents[0].correct 是否正确,Y 正常,N 不正确
data.contents[0].viewerAnswer 观众ID
data.contents[0].sessionId 直播场次Id
data.contents[0].times 同一道题发送多次,区分不同次数的
data.contents[0].submitTime 答题时间,时间戳
data.contents[0].submitTimeFormat 格式化的答题时间,格式为:yyyy/MM/dd HH:mm:ss
data.contents[0].costTime 答题耗时,单位秒
data.contents[0].costTimeFormat 格式化的答题耗时

php请求示例

<?php
//引用config.php
include 'config.php';
$params = array(
    'appId' => $appId,
    'timestamp' => $timestamp,
    'channelId' => 108888,
    'questionId' => "zxcvbnm",
    'times' => 1
);

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

$url = "https://api.polyv.net/live/v3/channel/question/answer-record/list-by-page?".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;
?>
联系客服,在线咨询