https://api.polyv.net/live/v3/user/statistics/viewlog
1、作用:分页获取用户的观看日志
2、接口支持https协议
{
"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
}
}
{
"code": 400,
"status": "error",
"message": "appId is required.",
"data": ""
}
{
"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": "startDate and endDate can not be empty.",
"data": ""
}
{
"code": 400,
"status": "error",
"message": "startDate can not great endDate.",
"data": ""
}
{
"code": 400,
"status": "error",
"message": "unable cross month query",
"data": ""
}
{
"code": 400,
"status": "error",
"message": "invalid channelId.",
"data": ""
}
<?php
//引用config.php
include 'config.php';
//接口需要的参数(非sign)赋值
$startDate = "2020-03-12";
$endDate = "2020-03-30";
$page = "1"; //页数
$pageSize="10";//每页显示的数据
$params = array(
'appId'=>$appId,
'startDate'=>$startDate,
'endDate'=>$endDate,
'page'=>$page,
'pageSize'=>$pageSize,
'timestamp'=>$timestamp
);
//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
//接口请求url
$url = "http://api.polyv.net/live/v3/user/statistics/viewlog?appId=$appId&startDate=startDate&endDate=endDate&page=$page&pageSize=$pageSize×tamp=$timestamp&sign=$sign";
//输出接口请求结果
echo file_get_contents($url);
?>