获取按频道汇总统计的播放数据

接口URL

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

接口说明

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

支持格式

JSON

请求方式

GET

请求数限制

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
        },
        {
            "userId": null,
            "channelId": 103669,
            "name": "直播回看1",
            "pcPlayDuration": 2943,
            "pcFlowSize": 3069092519,
            "pcVideoView": 1009,
            "pcUniqueViewer": 101,
            "mobilePlayDuration": 305,
            "mobileFlowSize": 0,
            "mobileVideoView": 104,
            "mobileUniqueViewer": 63
        }
    ]
}

响应失败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 移动端唯一观众数

php请求示例

<?php

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

//接口需要的参数(非sign)赋值
$userId = "XXXXXXXX";
$startDate = "2017-09-11";
$endDate = "2018-03-08";
$channelIds = "127075,127074,127071";

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

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

//接口请求url
$url = "http://api.polyv.net/live/v2/statistics/".$userId."/channel_summary?appId=".$appId."&timestamp=".$timestamp."&sign=".$sign."&endDate=".$endDate."&startDate=".$startDate."&channelIds=".$channelIds;
//输出接口请求结果
echo file_get_contents($url);

?>

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

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

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