Polyv Help Center

Help Center

Get Answer Summary for a Single Question on Answer Sheet

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

Interface URL

http://api.polyv.net/live/v3/channel/question/detail

Interface Description

1、接口用于获取答题卡单道题目的答题汇总
2、接口支持https

Request Method

GET

Request Parameters

Parameter Required Type Description
appId Yes string Obtained from API settings, the appId registered in the live streaming system
timestamp Yes long Current 13-digit millisecond timestamp, valid within 3 minutes
sign Yes string Signature, a 32-character uppercase MD5 value. The appSecret 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 to obtain response data. See signature generation rules
channelId Yes string Channel ID
questionId Yes string Question ID, obtained from the question list
times Yes int The nth occurrence of the answer details, used when the same question is sent multiple times. Obtained from the question list.

Successful Response JSON Example:

// 成功
{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
        "question": [
            {
                "count": 155,
                "tips": "",
                "option": "7"
            },
            {
                "count": 88,
                "tips": "",
                "option": "8"
            },
            {
                "count": 24,
                "tips": "",
                "option": "9"
            },
            {
                "count": 135,
                "tips": "",
                "option": "10"
            }
        ],
        "total": 402,
        "answer": "",
        "correctRecord": 0,
        "title": "请您为选手打分",
        "type": "S",
        "itemType": 0
    }
}

Failed Response JSON Examples:

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": ""
}

Field Description

Parameter Description
code Response status code, e.g., 200
status Response status
message Error message
data Response result set
data.question List of statistics for each option of the question
data.question[0].option Option of the question
data.question[0].count Selection count for the option
data.question[0].hint Hint for the option
data.total Total number of respondents
data.correctRecord Total number of correct answers
data.answer Answer to the question
data.title Question content
data.type Question type ("R": Single choice, "C": Multiple choice, "S": Rating, "Q": Q&A, "V": Voting)
data.itemType 0 for answer sheet, 1 for Q&A

PHP Request Example

<?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 = "http://api.polyv.net/live/v3/channel/question/detail?".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;
?>
联系客服,在线咨询