分页获取问卷结果

接口URL

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

接口说明

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

返回格式

JSON

请求方式

GET

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 当前13位毫秒级时间戳,3分钟内有效
sign string 签名,为32位大写的MD5值
channelId int 频道号
page int 页号,默认为1
pageSize int 每页大小,默认为10
startDate string 开始时间,格式:2018-12-10
endDate string 结束时间,格式:2018-12-10

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
        "pageNumber": 1,
        "totalItems": 3,
        "contents": [
            {
                "questionnaireId": "f7g2gtgtsd",
                "customQuestionnaireId": "xxxd33333",
                "questionnaireTitle": "ttt",
                "lastModified": 1544147881000,
                "endTime": 1544147981000,
                "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",
                        "submitTime": 1564384274000,
                        "totalScore": 0,
                        "answers": [
                            {
                                "questionId": "f7g2gtgtt9",
                                "questionName": "a",
                                "answer": "B",
                                "score": 0,
                                "type": "R"
                            },
                            {
                                "questionId": "f7g2gtgtyg",
                                "questionName": "b",
                                "answer": "B",
                                "score": 0,
                                "type": "R"
                            }
                        ]
                    }
                ]
            }
        ],
        "endRow": 3,
        "startRow": 1,
        "firstPage": true,
        "lastPage": true,
        "nextPageNumber": 1,
        "prePageNumber": 1,
        "totalPages": 1,
        "limit": 3,
        "offset": 0
    }
}

响应失败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 成功时,返回用户答题结果及各个题目的统计信息的分页信息
pageNumber 当前页数
totalItems 总条数
firstPage 是否为第一页,值为:true/false
lastPage 是否为最后一页,值为:true/false
nextPageNumber 下一页编号
prePageNumber 上一页编号
totalPages 总页数
limit 当前页数据条数
contents 频道的问卷信息和统计结果,是数组格式
questionnaireId 问卷ID,string
customQuestionnaireId 用户自定义问卷ID,string
questionnaireTitle 问卷名称,string
lastModified 问卷最后修改时间,13位毫秒级时间戳
endTime 问卷结束答题时间,13位毫秒级时间戳
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[].submitTime 提交问卷的用户答题时间,13位毫秒级时间戳
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 问答题

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/list-answer-records?".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...