Polyv Help Center

Help Center

Get Paginated User Answer Records by Question ID

Updated: 2022-09-02 18:08:07

Interface URL

http://api.polyv.net/live/v2/channels/{channelId}/get-question-record

Interface Description

1. Purpose: Retrieve paginated user answer records for a live quiz question.
2. The interface supports the HTTPS protocol.
3. The {channelId} in the interface URL represents the Channel ID.

Supported Format

JSON

Request Method

GET

Request Rate Limit

TRUE

Request Parameters

Parameter Required Type Description
appId Yes string Obtained from API settings, the appId registered in the live streaming system.
timestamp Yes string Current 13-digit millisecond timestamp, valid within 3 minutes.
page Yes string Page number.
pageSize No string Number of data items per page. Default is 1000 items per page.
questionId Yes string The question ID to query.
sign Yes String Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must not be stored or used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See signature generation rules

Successful Response JSON Example:

{
"code": 200,
"status": "success",
"message": "",
"data": {
"pageNumber": 1,
"totalItems": 1,
"contents": [
{
"recordId": "ezik85p9kw",
"channelId": 10001,
"questionId": "1c6dc3c666",
"viewerId": "oooii099",
"viewerName": "哈哈哈哈",
"answer": "a",
"createdTime": 1522032824000,
"lastModified": 1522032824000
}
],
"endRow": 1,
"lastPage": true,
"totalPages": 1,
"firstPage": true,
"startRow": 1,
"nextPageNumber": 1,
"prePageNumber": 1,
"offset": 0,
"limit": 1
}
}

Failed Response JSON Example:

No appId provided

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

Incorrect appId

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

Timestamp error

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

Signature error

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

No currentDay provided

{
    "code": 400,
    "status": "error",
    "message": "currentDay is empty.",
    "data": ""
}

Channel does not exist

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

Invalid channel ID

{
    "code": 403,
    "status": "error",
    "message": "invalid channelId.",
    "data": ""
}

Field Description

Parameter Description
code Response status code, e.g., 200.
status Response status.
message Error message.
data Response result set.
pageNumber Current page number.
totalItems Total number of items.
contents Query result list.
recordId Answer record ID.
channelId Channel ID.
questionId Question ID.
viewerId User ID of the answering user.
viewerName Nickname of the answering user.
answer Submitted option.
createdTime Creation date (13-digit timestamp).
lastModified Update date (13-digit timestamp).
firstPage Whether it is the first page, value: true/false.
lastPage Whether it is the last page, value: true/false.
nextPageNumber Next page number.
prePageNumber Previous page number.
totalPages Total number of pages.
startRow Position of the first record on the current page.
endRow Position of the last record on the current page.
limit Number of records on the current page.

PHP Request Example

<?php

//引用config.php
include 'config.php';

//接口需要的参数(非sign)赋值
$channelId = "124545";
$questionId = "1c6dc3c666";  
$page = "1"; //页数
$pageSize="10";//每页显示的数据

$params = array(
    'appId'=>$appId,
    'questionId'=>$questionId,
    'page'=>$page,
    'pageSize'=>$pageSize,
    'timestamp'=>$timestamp
  );

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

//接口请求url
$url = "http://api.polyv.net/live/v2/channels/$channelId/set-question-record?appId=$appId&questionId=$questionId&page=$page&pageSize=$pageSize&timestamp=$timestamp&sign=$sign";

//输出接口请求结果
echo file_get_contents($url);
  
?>
联系客服,在线咨询