分頁查詢頻道觀看日誌(包含簽到資訊)
更新時間: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);
?>
