分页查询用户观看日志

接口URL

https://api.polyv.net/live/v3/user/statistics/viewlog

接口说明

1、作用:分页获取用户的观看日志
2、接口支持https协议

返回结果支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名必选类型说明

appId

true

string

从API设置中获取,在直播系统登记的appId

timestamp

true

string

当前13位毫秒级时间戳,3分钟内有效

sign

true

String

签名,为32位大写的MD5值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据【详见签名生成规则

page

true

string

页数

pageSize

false

string

每页显示的数据条数,默认每页显示1000条数据

startDate

true 请查看下方注意点

string

查询开始时间,格式:yyyy-MM-dd

endDate

true 请查看下方注意点

string

查询结束时间,格式:yyyy-MM-dd

channelId

false

int

频道ID

注意

  1. 如果查询一段时间的记录,可以传:startDate、endDate (startDate和endDate 必须在同一个月);

响应成功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": ""
}

查询的开始和结束时间有为空的情况

{
    "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": ""
}

非法的频道ID

{
    "code": 400,
    "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)赋值
$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&timestamp=$timestamp&sign=$sign";

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

Last updated