查询多个频道汇总的统计数据

接口URL

http://api.polyv.net/live/v2/statistics/{userId}/channel_summary

接口说明

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

1、根据是否提交channelIds来获取全部频道/某个频道查询时间内的播放数据
2、接口URL中的{userId}为直播账号ID
3、接口支持https

返回结果支持格式

JSON

请求方式

GET,POST

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp string 当前13位毫秒级时间戳,3分钟内有效
sign string 签名,为32位大写的MD5值
startDate string 查询的开始日期 格式为yyyy-MM-dd
endDate string 查询的结束日期 格式为yyyy-MM-dd
channelIds string 要查询的频道号,不提交默认为查询所有频道,多个频道号以英文逗号“,”分开,如:105420,104400

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": [
        {
            "userId": null,
            "channelId": 101385,
            "name": "测试频道号12",
            "pcPlayDuration": 3738,
            "pcFlowSize": 14585121564,
            "pcVideoView": 944,
            "pcUniqueViewer": 138,
            "mobilePlayDuration": 399,
            "mobileFlowSize": 7937281,
            "mobileVideoView": 195,
            "mobileUniqueViewer": 71,
            "livePcPlayDuration": 38,
            "playbackPcPlayDuration": 0,
            "unknownPcPlayDuration": 0,
            "liveMobilePlayDuration": 0,
            "playbackMobilePlayDuration": 0,
            "unknownMobilePlayDuration": 0
        },
        {
            "userId": null,
            "channelId": 103669,
            "name": "直播回看1",
            "pcPlayDuration": 2943,
            "pcFlowSize": 3069092519,
            "pcVideoView": 1009,
            "pcUniqueViewer": 101,
            "mobilePlayDuration": 305,
            "mobileFlowSize": 0,
            "mobileVideoView": 104,
            "mobileUniqueViewer": 63,
            "livePcPlayDuration": 38,
            "playbackPcPlayDuration": 0,
            "unknownPcPlayDuration": 0,
            "liveMobilePlayDuration": 0,
            "playbackMobilePlayDuration": 0,
            "unknownMobilePlayDuration": 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": "日期格式要求为yyyy-MM-dd.",
    "data": ""
}

channelIds格式错误

{
    "code": 400,
    "status": "error",
    "message": "channelIds is wrong.",
    "data": ""
}

channelds的频道号不属于当前账号

{
    "code": 400,
    "status": "error",
    "message": "channelIds is mismatching.",
    "data": ""
}

字段说明

参数名 说明
code 请求状态响应码
status 请求状态
message 错误信息
channelId 频道Id
name 频道名称
pcPlayDuration pc端播放时长,单位:分钟
pcFlowSize pc端播放流量,单位为Byte
pcVideoView pc视频播放量
pcUniqueViewer pc端唯一观众数
mobilePlayDuration 移动端播放时长,单位:分钟
mobileFlowSize 移动端播放流量,单位为Byte
mobileVideoView 移动端播放量
mobileUniqueViewer 移动端唯一观众数
livePcPlayDuration PC直播播放时长,单位为分钟
playbackPcPlayDuration PC回放播放时长,单位为分钟
liveMobilePlayDuration 移动端直播播放时长,单位为分钟
playbackMobilePlayDuration 移动端回放播放时长,单位为分钟
unknownPcPlayDuration pc 其他 播放时长,单位为分钟
unknownMobilePlayDuration 移动端其他 播放时长,单位为分钟

php请求示例

<?php
//引用config.php
include 'config.php';
//接口需要的参数(非sign)赋值
$userId = "";
$startDate = "";
$endDate = "";
$channelIds = "";

$params = array(
    'appId'=>$appId,
    'startDate'=>$startDate,
    'endDate'=>$endDate,
    'channelIds'=>$channelIds,
    'timestamp'=>$timestamp
  );

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
$params['sign'] = $sign;
$header = array("Content-Type:x-www-form-urlencoded");
//接口请求url
$url = "http://api.polyv.net/live/v2/statistics/".$userId."/channel_summary";
//输出接口请求结果
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 5000);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
$res = curl_exec($curl);
curl_close($curl);

echo $res;

?>

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

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

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