取得直播頻道某天的數據統計
更新時間:2023-11-14 14:07:19
介面URL
http://api.live.polyv.net/v2/statistics/{channelId}/summary
介面說明
透過頻道號(channelId)取得該頻道某段時間的直播統計數據。
支援格式
JSON
請求方式
GET
請求數限制
TRUE
請求參數
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| startDay | 是 | yyyy-MM-dd的日期字串 | 要查詢的資料的開始日期 |
| endDay | 是 | yyyy-MM-dd的日期字串 | 要查詢的資料的結束日期 |
| appId | 是 | string | 使用者的appId |
| timestamp | 是 | 10位或13位的時間戳均可 | 時間戳 |
| sign | 是 | string | 加密串 |
回應成功JSON範例:
{
status: "success",
result: [
{
currentDay: "2017-08-02",
channelId: 101378,
userId: "edv3kno3t5",
pcPlayDuration: 18,
pcFlowSize: 7533133,
pcVideoView: 3,
pcUniqueViewer: 1,
mobilePlayDuration: 10,
mobileFlowSize: 0,
mobileVideoView: 6,
mobileUniqueViewer: 2,
createdTime: 1501697384000,
lastModified: 1501697384000
}, {
currentDay: "2017-08-03",
channelId: 101378,
userId: "edv3kno3t5",
pcPlayDuration: 34,
pcFlowSize: 23014636,
pcVideoView: 10,
pcUniqueViewer: 1,
mobilePlayDuration: 16,
mobileFlowSize: 0,
mobileVideoView: 5,
mobileUniqueViewer: 2,
createdTime: 1501783204000,
lastModified: 1501783204000
}, {
currentDay: "2017-08-04",
channelId: 101378,
userId: "edv3kno3t5",
pcPlayDuration: 3,
pcFlowSize: 0,
pcVideoView: 1,
pcUniqueViewer: 1,
mobilePlayDuration: 0,
mobileFlowSize: 0,
mobileVideoView: 0,
mobileUniqueViewer: 0,
createdTime: 1501816874000,
lastModified: 1501816874000
}
]}
回應失敗JSON範例:
{
code: "invalid.request",
msg: "signature error."
}
欄位說明
| 參數名 | 說明 |
|---|---|
| currentDay | 當期日期:yyyy-MM-dd |
| channelId | 直播頻道ID |
| userId | 使用者ID |
| pcPlayDuration | PC端播放時長,單位:分鐘 |
| pcFlowSize | PC端消耗流量,單位:bytes |
| pcVideoView | PC端總播放量,類似PV |
| pcUniqueViewer | PC端唯一觀眾數,類似UV |
| mobilePlayDuration | 行動端播放時長,單位:分鐘 |
| mobileFlowSize | 行動端消耗流量,單位:bytes |
| mobileVideoView | 行動端總播放量,類似PV |
| mobileUniqueViewer | 行動端唯一觀眾數,類似UV |
| mobileUniqueViewer | 行動端唯一觀眾數,類似UV |
| mobileUniqueViewer | 行動端唯一觀眾數,類似UV |
| createdTime | 記錄新增的時間 |
| lastModified | 記錄修改的時間 |
php請求範例
<?php
header("Content-type: textml; charset=utf-8");
$startDay="2017-08-02";
$endDay="2017-08-08";
$appId="egzhqa99ud";
$timestamp= time()*1000;
$appSecret = "60a0563af8c141e3b2c5b91429fbbc66";
$str=$appSecret."appId".$appId."endDay".$endDay."startDay".$startDay."timestamp".$timestamp.$appSecret;
$sign = md5($str);
$sign = strtoupper($sign);
$url = "http://api.live.polyv.net/v2/statistics/101378/summary?timestamp=$timestamp&sign=$sign&endDay=$endDay&startDay=$startDay&appId=$appId";
$ch = curl_init() or die ( curl_error() );
curl_setopt( $ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 360);
$response = curl_exec ( $ch );
curl_close ( $ch );
echo $response;
?>
簽名規則:
sign產生範例:
1、將請求參數按照參數名字典順序排列為
ptime = "1501055103000"
startDay="2017-08-02"
endDay="2017-08-08"
appId="egzhqa99ud"
2、連接字串 連接參數名與參數值,並在首尾加上secretkey(此處secretkey的值為60a0563af8c141e3b2c5b91429fbbc66),如下:
"60a0563af8c141e3b2c5b91429fbbc66" + "appId" +
"egzhqa99ud" + "endDay" + "2017-08-08" + "ptime" +
"1501055103000" + "startDay" + "2017-08-02" + "60a0563af8c141e3b2c5b91429fbbc66"
3、sign為32位大寫的MD5值
C758DF8045929D51CA28D51B934C9AAC
