查询用户下的历史并发数据
接口URL
https://api.polyv.net/live/v3/user/statistics/concurrence
接口说明
1、接口用于获取用户在某个日期区间并发人数(按照时间升序排序)
2、接口支持https
支持格式
JSON
请求方式
GET
请求数限制
TRUE
请求参数
参数名
必选
类型
说明
appId
是
string
从API设置中获取,在直播系统登记的appId
timestamp
是
long
当前13位毫秒级时间戳,3分钟内有效
sign
是
String
签名,为32位大写的MD5值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据
【详见签名生成规则】
startDate
是
string
开始日期格式,yyyy-MM-dd
endDate
是
string
结束日期格式,yyyy-MM-dd
备注:开始日期和结束日期的时间跨度:最多查两个月内的数据
响应成功JSON示例:
{
"code": 200,
"status": "success",
"message": "",
"data": [{
"day": "2019-04-10",
"minute": "10:30",
"viewers": 2
}, {
"day": "2019-04-16",
"minute": "19:06",
"viewers": 2
}]
}
响应失败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": "param is not digit: dsadasd",
"data": ""
}
日期范围错误
{
"code": 400,
"status": "error",
"message": "startDate can not great endDater",
"data": ""
}
字段说明
参数名
说明
code
响应代码,成功为200,失败为400,签名错误为401,异常错误500
status
成功为success,失败为error
message
错误时为错误提示消息
data
日期区间内的历史并发人数
php请求示例
<?php
//引用config.php
include 'config.php';
$params = array(
'appId' => $appId,
'timestamp' => $timestamp,
'startDate' => 2019-04-01,
'endDate' => 2019-05-01
);
//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
$params['sign'] = $sign;
$url = "http://api.polyv.net/live/v3/user/statistics/concurrence?".http_build_query($params);
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 0);
$res = curl_exec($curl);
curl_close($curl);
echo $res;
?>
Last updated
Was this helpful?