获取直播频道某天的数据统计

接口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

Last updated

Was this helpful?