Query Historical Concurrent Data for a User
Updated: 2022-09-02 18:08:07
Interface URL
https://api.polyv.net/live/v3/user/statistics/concurrence
Interface Description
1、接口用于获取用户在某个日期区间并发人数(按照时间升序排序)
2、接口支持https
Supported Format
JSON
Request Method
GET
Request Limit
TRUE
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | Yes | string | Obtained from API settings, the appId registered in the live streaming system |
| timestamp | Yes | long | Current 13-digit millisecond timestamp, valid within 3 minutes |
| sign | Yes | String | Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must not be stored or used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. For details, see Signature Generation Rules |
| startDate | Yes | string | Start date format: yyyy-MM-dd |
| endDate | Yes | string | End date format: yyyy-MM-dd |
Note: The time span between start date and end date: maximum query of data within two months
Successful Response JSON Example:
{
"code": 200,
"status": "success",
"message": "",
"data": [{
"day": "2019-04-10",
"minute": "10:30",
"viewers": 2
}, {
"day": "2019-04-16",
"minute": "19:06",
"viewers": 2
}]
}
Failed Response JSON Examples:
appId not provided
{
"code": 400,
"status": "error",
"message": "appId is required.",
"data": ""
}
Incorrect appId
{
"code": 400,
"status": "error",
"message": "application not found.",
"data": ""
}
Timestamp error
{
"code": 400,
"status": "error",
"message": "invalid timestamp.",
"data": ""
}
Signature error
{
"code": 403,
"status": "error",
"message": "invalid signature.",
"data": ""
}
Channel number format error
{
"code": 400,
"status": "error",
"message": "param is not digit: dsadasd",
"data": ""
}
Date range error
{
"code": 400,
"status": "error",
"message": "startDate can not great endDater",
"data": ""
}
Field Description
| Parameter | Description |
|---|---|
| code | Response code: 200 for success, 400 for failure, 401 for signature error, 500 for exception error |
| status | success for success, error for failure |
| message | Error message when an error occurs |
| data | Historical concurrent user count within the date range |
PHP Request Example
<?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;
?>
