保利威文档中心

幫助中心

分頁取得答題卡的答題觀眾列表

更新時間: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;
?>
联系客服,在线咨询