分页查询频道观看日志

接口URL

http://api.polyv.net/live/v2/statistics/{channelId}/viewlog

接口说明

1、作用:分页获取频道的观看日志
2、接口支持https协议
3、接口URL中的{channelId}为 频道ID

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名 必选 类型 说明
appId string 从API设置中获取,在直播系统登记的appId
timestamp string 当前13位毫秒级时间戳,3分钟内有效
page string 页数
pageSize string 每页显示的数据条数,默认每页显示1000条数据
currentDay 请查看下方注意点 string 查询日期,格式:yyyy-MM-dd
startTime 请查看下方注意点 string 查询开始时间,为13位毫秒级时间戳
endTime 请查看下方注意点 string 查询结束时间,13位毫秒级时间戳
param1 string 观看用户ID
param2 string 观看用户昵称
param3 string 观看日志类型
sign string 签名,32位大写MD5值

注意
1. 如果查询一段时间的记录,可以传:startTime、endTime (startTime和endTime 必须在同一个月),如果查询某天的记录,则传currentDay;
2. startTime、endTime 和 currentDay不能都不传;
3. currentDay与startTime、endTime 同时传将使用currentDay的值。

响应成功JSON示例:

{
    "code": 200, 
    "status": "success", 
    "message": "", 
    "data": {
        "pageNumber": 1, 
        "totalItems": 3, 
        "contents": [
{
"playId": "1520501687122X1438160",
"userId": "1c6dc3c666",
"channelId": 151462,
"playDuration": 341,
"stayDuration": 361,
"flowSize": 10028116,
"sessionId": "eyz0awxrlh",
"param1": "1520499775580",
"param2": "广州观众/78614",
"param3": "live",
"param4": "",
"param5": "",
"ipAddress": "59.42.41.1",
"country": "中国",
"province": "广东",
"city": "广州",
"isp": "/南沙区电信",
"referer": "https://live.polyv.cn/watch/151462",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36",
"operatingSystem": "Mac OS X",
"browser": "Chrome",
"isMobile": "N",
"currentDay": "2018-03-08",
"createdTime": 1520501705000,
"lastModified": 1520504494000
}, 
{
"playId": "1520501157256X1429802",
"userId": "1c6dc3c666",
"channelId": 151462,
"playDuration": 29,
"stayDuration": 528,
"flowSize": 1068201,
"sessionId": "eyz0awxrlh",
"param1": "1520499775580",
"param2": "广州观众/78614",
"param3": "live",
"param4": "",
"param5": "",
"ipAddress": "59.42.41.1",
"country": "中国",
"province": "广东",
"city": "广州",
"isp": "/南沙区电信",
"referer": "https://live.polyv.cn/watch/151462",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36",
"operatingSystem": "Mac OS X",
"browser": "Chrome",
"isMobile": "N",
"currentDay": "2018-03-08",
"createdTime": 1520501664000,
"lastModified": 1520504494000
}, 
            {
"playId": "1520500551108X1714565",
"userId": "1c6dc3c666",
"channelId": 151462,
"playDuration": 18,
"stayDuration": 20,
"flowSize": 3048444,
"sessionId": "eyz0awxrlh",
"param1": "1520499775580",
"param2": "广州观众/78614",
"param3": "live",
"param4": "",
"param5": "",
"ipAddress": "59.42.40.205",
"country": "中国",
"province": "广东",
"city": "广州",
"isp": "/南沙区电信",
"referer": "https://live.polyv.cn/watch/151462",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36",
"operatingSystem": "Mac OS X",
"browser": "Chrome",
"isMobile": "N",
"currentDay": "2018-03-08",
"createdTime": 1520500572000,
"lastModified": 1520503294000
}
        ], 
        "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": ""
}

未输入currentDay

{
    "code": 400,
    "status": "error",
    "message": "currentDay is empty.",
    "data": ""
}

频道不存在

{
    "code": 400,
    "status": "error",
    "message": "channel not found.",
    "data": ""
}

非法的频道ID

{
    "code": 403,
    "status": "error",
    "message": "invalid channelId.",
    "data": ""
}

字段说明

参数名 说明
code 响应的状态码,例如:200
status 响应状态
message 异常错误信息
data 响应结果集
pageNumber 当前的页数
totalItems 总的条数
contents 查询的结果列表
playId 表示此次播放动作的ID
userId 用户ID
channelId 频道号
playDuration 播放时长
stayDuration 缓存时长
flowSize 流量大小
sessionId 直播场次ID
param1 使用POLYV观看页的观众ID
param2 使用POLYV观看页的观众昵称
param3 观看类型:取值 live(直播)、vod(回放)
param4/5 POLYV系统参数
ipAddress IP地址
country 国家
province 省份
city 城市
isp ISP运营商
referer 播放视频页面地址
userAgent 用户设备
operatingSystem 操作系统
browser 浏览器
isMobile 是否为移动端
currentDay 日志查询日期 (格式为:yyyy-MM-dd)
createdTime 日志创建日期 (13位时间戳)
lastModified 日志更新日期 (13位时间戳)
firstPage 是否为第一页,值为:true/false
lastPage 是否为最后一页,值为:true/false
nextPageNumber 下一页编号
prePageNumber 上一页编号
totalPages 总页数
startRow 当前页第一个视频在回放视频中的位置
endRow 当前页最后一个视频在回放视频中的位置
limit 当前页视频个数

php请求示例

<?php

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

//接口需要的参数(非sign)赋值
$channelId = "124545";
$currentDay = "2018-03-12";  
$page = "1"; //页数
$pageSize="10";//每页显示的数据

$params = array(
    'appId'=>$appId,
    'currentDay'=>$currentDay,
    'page'=>$page,
    'pageSize'=>$pageSize,
    'timestamp'=>$timestamp
  );

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

//接口请求url
$url = "http://api.polyv.net/live/v2/statistics/$channelId/viewlog?appId=$appId&currentDay=$currentDay&page=$page&pageSize=$pageSize&timestamp=$timestamp&sign=$sign";

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

?>

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

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

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