Polyv Help Center

Help Center

Batch Create Answer Sheets

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

Interface URL

https://api.polyv.net/live/v3/channel/question/batch-save

Interface Description

Batch create answer sheets, creating a set of live channel answer sheet templates and their corresponding template questions.

Supported Format

JSON

Request Method

POST

Request Parameters

Parameter Name Required Type & Scope 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 for 3 minutes
sign Yes String Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical information for communication data security. It must not be stored directly on the client. 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
channelId Yes string Channel ID
name No string Template name. If not provided, no answer sheet template data will be generated
status No string Template status: unused (upload successful), used (in use)
questions[].identifyId No string Record question ID. After a successful API call, this ID will correspond to the system's questionId
questions[].name Yes string Question name
questions[].type Yes string Question type: R (single choice), C (multiple choice), S (rating)
questions[].option1 No string Option 1. Options cannot all be empty simultaneously. If data exists, it must be continuous
questions[].option2 No string Option 2. Options cannot all be empty simultaneously. If data exists, it must be continuous
questions[].option3 No string Option 3. Options cannot all be empty simultaneously. If data exists, it must be continuous
questions[].option4 No string Option 4. Options cannot all be empty simultaneously. If data exists, it must be continuous
questions[].option5 No string Option 5. Options cannot all be empty simultaneously. If data exists, it must be continuous
questions[].answer No string When questions[].type is rating, this is optional. For single choice and multiple choice, it is the answer. E.g., ABC for multiple choice, A for single choice (single choice cannot have two answers)
questions[].tips1 No string When questions[].type is rating, pass the corresponding value for option1, i.e., the score hint
questions[].tips2 No string When questions[].type is rating, pass the corresponding value for option2, i.e., the score hint
questions[].tips3 No string When questions[].type is rating, pass the corresponding value for option3, i.e., the score hint
questions[].tips4 No string When questions[].type is rating, pass the corresponding value for option4, i.e., the score hint
questions[].tips5 No string When questions[].type is rating, pass the corresponding value for option5, i.e., the score hint

Note: The channelId, appId, timestamp, and sign must be passed via URL parameters. The JSON data is passed via the request body. Example: https://api.polyv.net/live/v3/channel/questionnaire/add-edit-questionnaire?channelId={{channelId}}&appId={{appId}}&timestamp={{timestamp}}&sign={{sign}}

Body Input Example

{
    "name":"nana",
    "questions": [
        {
            "identifyId": "123",
            "name":"第一题",
            "type":"R",
            "option1": "哈哈",
            "option2": "测试",
            "answer":"A"
        }
    ]
}

Return Result

// 成功结果
{
    "code": 200,
    "status": "success",
    "message": "success",
    "data": {
        "templateId": "xxxxxx",
        "questionKey": {
            "123": "xxxxx",
            "identifyId2": "questionId2"
        }
    }
}

Failure Return 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": 400,
  "status": "error",
  "message": "param is not digit: dsadasd",
  "data": ""
}

Response Parameter Description

Field Description Type
code Response code int32
status Response status: success/error/fail string
message Error message description string
data Response data object
data.templateId Template templateId string
data.questionKey Template questions. The identifyId parameter corresponds to the system's primary key questionId. This is an object in key-value format. If you do not need to map questions to the system's questionId, this parameter can be ignored Object

Response Error Description

Error Code message Description
400 appId is required. appId not provided
400 application not found. Incorrect appId
400 invalid timestamp. Timestamp error
400 invalid signature. Signature error
400 param is not digit: dsadasd Incorrect channel ID format
400 type illegal. type T. Incorrect question type
400 xxxx name is blank The question title for identifyId is blank
400 xxxx answer is blank The answer for identifyId is blank
400 xxxx options are all blank All options for identifyId are blank
400 xxxx options are discontinuous Options for identifyId are not continuous
400 xxxx answer's option is empty The option corresponding to the answer for identifyId is empty
400 xxxx illegal answer Invalid answer for identifyId

PHP Request Example

<?php

$appId="xxxxxxxxxxx";
$timestamp=time()*1000;
$url = 'https://api.polyv.net/live/v3/channel/question/batch-save?';
$header = array('application/json');
$data = array(
    'appId' => $appId,
    'timestamp' => $timestamp,
    'channelId' => 206204
);
$data["sign"]=$hash;
$json = '{
    "name":"nana",
    "questions": [
        {
            "identifyId": "123",
            "name":"第一题",
            "type":"R",
            "option1": "哈哈",
            "option2": "测试",
            "answer":"A"
        }
    ]
}'
// 请求接口
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url.http_build_query($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$sResult = curl_exec($ch);
if($sError=curl_error($ch)){
    die($sError);
}
curl_close($ch);
//打印获得的数据
print_r($sResult);
?>
联系客服,在线咨询