分页查询频道观看日志(包含签到信息)
更新时间:2022-09-02 18:08:07
接口URL
http://api.polyv.net/live/v3/channel/statistics/viewlog-with-checkin
接口说明
1、作用:分页获取频道带有学员签到信息的观看日志
2、接口支持https协议
3、接口URL中的{channelId}为 频道ID
支持格式
JSON
请求方式
GET
请求参数
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| appId | 是 | string | 从API设置中获取,在直播系统登记的appId |
| channelId | 是 | int | 频道ID |
| 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值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据【详见签名生成规则】 |
注意:
- 如果查询一段时间的记录,可以传:startTime、endTime (startTime和endTime 必须在同一个月),如果查询某天的记录,则传currentDay;
- startTime、endTime 和 currentDay不能都不传;
- 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,
"leftTime":1520507705000,
"firstTime": null,
"lastTime": null,
"num": 0
},
{
"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,
"leftTime":1520507705000,
"firstTime": null,
"lastTime": null,
"num": 0
},
{
"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,
"firstTime": 1520501234000,
"lastTime": 1520505678000,
"num": 3
}
],
"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位时间戳) |
| leftTime | 离开直播时间 (13位时间戳) |
| firsTime | 该场直播中首次签到时间 (13位时间戳),没有签到信息时返回为null |
| lastTime | 该场直播中最后一次签到的时间(13位时间戳),没有签到信息时返回为null |
| num | 该场直播的签到次数,没有签到信息返回为0 |
| 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/v3/channel/statistics/viewlog-with-checkin?appId=$appId&channelId=$channelId¤tDay=$currentDay&page=$page&pageSize=$pageSize×tamp=$timestamp&sign=$sign";
//输出接口请求结果
echo file_get_contents($url);
?>
