查询频道答题卡答题结果

接口URL

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

接口说明

1、接口用于获取频道的答题卡答题结果列表
2、接口支持https

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp long 13位当前时间戳
sign string 签名值
channelId int 频道号
startDate string 查询的开始时间
endDate string 查询的结束时间

ps:开始和结束时间为空的默认查最近7天的数据。

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": [
        {
            "questionId": "f31lrsr9vx",
            "questionTitle": "测试1",
            "answer": "B",
            "total": 1,
            "correctCount": 0,
            "options": [
                {
                    "title": ",,",
                    "count": 1,
                    "percent": "100.00%"
                },
                {
                    "title": "..",
                    "count": 0,
                    "percent": "0.00%"
                }
            ],
            "records": [
                {
                    "viewerId": "1531987278863",
                    "nickname": "广州观众/79713",
                    "answer": "A",
                    "corrent": false,
                    "submitTime": 1538202386000
                }
            ]
        },
        {
            "questionId": "f31lr45sjl",
            "questionTitle": "测试1",
            "answer": "A",
            "total": 1,
            "correctCount": 1,
            "options": [
                {
                    "title": "nn",
                    "count": 1,
                    "percent": "100.00%"
                },
                {
                    "title": "m,m",
                    "count": 0,
                    "percent": "0.00%"
                }
            ],
            "records": [
                {
                    "viewerId": "1531987278863",
                    "nickname": "广州观众/79713",
                    "answer": "A",
                    "corrent": false,
                    "submitTime": 1538202386000
                }
            ]
        }
    ]
}

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

channelId为空

{
  "code": 400, 
  "status": "error", 
  "message": "param should not be empty: channelId", 
  "data": ""
}

channelId为非数字

{
  "code": 400, 
  "status": "error", 
  "message": "param is not number: channelId", 
  "data": ""
}

频道非法

{
  "code": 403, 
  "status": "error", 
  "message": "illegal channel id: 206240", 
  "data": ""
}

字段说明

参数名 说明
code 响应代码,成功为200,失败为400,签名错误为401,异常错误500
status 成功为success,失败为error
message 错误时为错误提示消息
data 答题结果列表数据
questionId 答题ID
answer 题目的答案
total 答题人数
options 题目选项信息列表
title 选项标题
count 选择该选项的人数
percent 选择该选项的人数百分比
records 答题的用户列表
viewerId 答题的用户ID
nickname 答题的用户昵称
answer 答题的用户提交的答案
corrent 答题的用户提交的答案是否正确:false不正确,true正确
submitTime 答题的用户提交时间,13位毫秒级时间戳

php请求示例

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

$channelId="206204";

$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp,
  'channelId' => $channelId,
  'startDate' => '2018-07-01',
  'endDate' => '2018-07-18'
);

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

$url = "https://api.polyv.net/live/v3/channel/question/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);
$res = curl_exec($curl);
curl_close($curl);

echo $res;
?>

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

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

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

发送点赞

接口URL

http://api.polyv.net/live/v2/channels/{channelId}/like

接口说明

1、用于实现用户自开发观看页点赞效果,通过调用接口可以进行点赞,默认每次请求都是一次点赞
2、接口内部进行了判断,每个观众的点赞间隔1s的限制,根据提交的观众ID来区分
3、如果有需求支持同时点多个赞,可提交非必填参数times,times最大不能超过30。*如果提交次数为n,则需n-1秒才能继续点赞
4、接口支持https
5、接口URL中的{channelId}为 频道ID

支持格式

JSON

请求方式

GET  POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp string 当前13位毫秒级时间戳,3分钟内有效
sign string 签名,32位大写MD5值
viewerId string 点赞观众的ID
times int 点赞的数目,不能超过30,提交后在times-1秒后才能再点赞

响应成功JSON示例:

{
    "code": 200, 
    "status": "success", 
    "message": "", 
    "data": 288
}

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

未提交viewerID

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

点赞间隔小于1s

{
    "code": 400,
    "status": "error",
    "message": "您的操作过快,请稍后再试",
    "data": ""
}

点赞次数times大于30

{
    "code": 400,
    "status": "error",
    "message": "设置的次数过多,请稍后再试",
    "data": ""
}

字段说明

参数名 说明
code 请求状态响应码
status 请求状态
message 错误信息
data 请求成功时为点赞数,请求错误时为空

php请求示例

<?php

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

//接口需要的参数(非sign)赋值
$channelId = "127075";
$times = 16;
$viewerId = '123123';

$params = array(
    'appId'=>$appId,
    'times'=>$times,
    'viewerId'=>$viewerId,
    'timestamp'=>$timestamp
  );

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

//接口请求url
$url = "http://api.polyv.net/live/v2/channels/$channelId/like?appId=$appId&timestamp=$timestamp&sign=$sign&viewerId=$viewerId&times=$times";

//输出接口请求结果
echo file_get_contents($url);

?>

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

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

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