查询频道问卷结果

接口URL

https://api.polyv.net/live/v3/channel/questionnaire/answer-records

接口说明

(接口调用有频率限制,详细请查看)

1、接口用于查询直播问卷的答题结果及统计
2、接口支持https

返回结果支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 当前13位毫秒级时间戳,3分钟内有效
sign string 签名,为32位大写的MD5值
channelId int 频道号
startDate string 开始时间,格式:2018-12-10
endDate string 结束时间,格式:2018-12-10
questionnaireId string 问卷ID,和startDate/endDate同时提交时,会优先以该参数查询

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": [
        {
            "questionnaireId": "f7g2gtgtsd",
            "customQuestionnaireId": "dkki24kjdj",
            "questionnaireTitle": "ttt",
            "questionStats": {
                "questions": [
                    {
                        "questionId": "f7g2gtgtt9",
                        "score": 10,
                        "totalScore": 10,
                        "total": 2,
                        "correctCount": 1,
                        "d": 0,
                        "e": 0,
                        "f": 0,
                        "h": 0,
                        "i": 0,
                        "j": 0,
                        "c": 0,
                        "a": 1,
                        "b": 1,
                        "g": 0
                    },
                    {
                        "questionId": "f7g2gtgtyg",
                        "score": 10,
                        "totalScore": 10,
                        "total": 2,
                        "correctCount": 1,
                        "d": 0,
                        "e": 0,
                        "f": 0,
                        "h": 0,
                        "i": 0,
                        "j": 0,
                        "c": 0,
                        "a": 1,
                        "b": 1,
                        "g": 0
                    }
                ],
                "total": 2
            },
            "users": [
                {
                    "viewerId": "1544406042082",
                    "nickname": "广州观众/98347",
                    "totalScore": 20,
                    "answers": [
                        {
                            "questionId": "f7g2gtgtt9",
                            "questionName": "a",
                            "answer": "A",
                            "score": 10,
                            "type": "R"
                        },
                        {
                            "questionId": "f7g2gtgtyg",
                            "questionName": "b",
                            "answer": "A",
                            "score": 10,
                            "type": "R"
                        }
                    ]
                },
                {
                    "viewerId": "oL0En04rCbHNSNdey_rFMAkLT-Ps",
                    "nickname": "ilyq69",
                    "totalScore": 0,
                    "answers": [
                        {
                            "questionId": "f7g2gtgtt9",
                            "questionName": "a",
                            "answer": "B",
                            "score": 0,
                            "type": "R",
                            "param4": "",
                            "param5": null
                        },
                        {
                            "questionId": "f7g2gtgtyg",
                            "questionName": "b",
                            "answer": "B",
                            "score": 0,
                            "type": "R",
                            "param4": "",
                            "param5": null
                        }
                    ]
                }
            ]
        }
    ]
}

响应失败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": ""
}

字段说明

参数名 说明
code 响应代码,成功为200,失败为400,签名错误为401,异常错误500(http状态码也跟code相同)
status 成功为success,失败为error
message 错误时为错误提示消息
data 成功时,返回用户答题结果及各个题目的统计信息,是个数组
questionnaireId 问卷ID,string
customQuestionnaireId 用户自定义问卷ID,string
questionnaireTitle 问卷名称,string
questionStats 问卷下各个问题的答题统计
questionStats.total 题目的答题人数,int
questionStats.questions 题目的答题统计信息,数组[]
questionStats.questions[].questionId 题目ID,string
questionStats.questions[].questionName 题目名称,string
questionStats.questions[].score 题目分数,int
questionStats.questions[].totalScore 题目的总得分,int
questionStats.questions[].correctCount 题目的答对人数,int
questionStats.questions[].a-g 选择项a到g分别的答题人数,int
users 观看端提交答题的信息
users[].viewerId 提交问卷的用户ID,string
users[].nickname 提交问卷的用户昵称,string
users[].totalScore 提交问卷的用户的总得分,int
users[].answers[] 用户每道题目的答题情况,数组 []
users[].answers[].questionId 题目ID,string
users[].answers[].questionName 题目名称,string
users[].answers[].answer 提交的题目答案,string
users[].answers[].score 用户答题的得分,string
users[].answers[].type 题目的类型,string,R 单选题 ,C 多项题 ,Q 问答题
users[].answers[].param4 在外部授权、直接(独立)授权情况下传过来的自定义参数
users[].answers[].param5 在外部授权、直接(独立)授权情况下传过来的自定义参数

php请求示例

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

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => 195770,
  'startDate' => '2018-12-08',
  'endDate' => '2018-12-10'  
);

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

$url = "http://api.polyv.net/live/v3/channel/questionnaire/answer-record?".http_build_query($params);

$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
$res = curl_exec($curl);
curl_close($curl);

echo $res;
?>

签名规则(config.php文件代码查看)

http://dev.polyv.net/2018/liveproduct/l-api/rule/sign/

以上内容是否对您有帮助?根本没有帮助文档较差文档一般文档不错文档很好
Loading...