Query Category Play Count, Traffic, and Play Duration Statistics by Date Range or Time Period
Updated: 2022-05-23 18:01:52
Interface URL
https://api.polyv.net/v2/cata/{userid}/stats-info
Interface Description
Query category play count, traffic, and play duration statistics by date range or time period
Supported Format
JSON
Request Method
GET
Request Parameters
| Parameter | Required | Type & Range | Description |
|---|---|---|---|
| userid | true | string | User ID, path parameter |
| ptime | true | string | Current 13-digit millisecond timestamp, valid for 3 minutes |
| sign | true | string | Signature, 40-character uppercase SHA1 value |
| cataid | true | long | Category ID |
| dr | false | string | Time period, possible values: today, yesterday, this_week, last_week, 7days, this_month, last_month, this_year, last_year. Default: 7days |
| startDate | false | string | Start date, format: yyyy-MM-dd |
| endDate | false | string | End date, format: yyyy-MM-dd |
| containSubCategory | false | string | Whether to include subcategory statistics. Y = include, N = exclude |
Return Result
{
"code": 4,
"status": "text",
"message": "",
"data": [
{
"current": "2018-08-01",
"pcFlowSize": 10,
"mobileFlowSize": 0,
"mobilePlayDuration": 9,
"pcPlayDuration": 2,
"pcVideoView": 9,
"mobileVideoView": 7
},
{
"current": "2018-08-02",
"pcFlowSize": 10,
"mobileFlowSize": 1000,
"mobilePlayDuration": 9,
"pcPlayDuration": 20,
"pcVideoView": 90,
"mobileVideoView": 7
}
]
}
Failure Return JSON (without JSONP)
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
Field Description
| Field Name | Description |
|---|---|
| current | Query date |
| pcFlowSize | PC traffic |
| mobileFlowSize | Mobile traffic |
| mobilePlayDuration | Mobile play duration |
| pcPlayDuration | PC play duration |
| pcVideoView | PC play count |
| mobileVideoView | Mobile play count |
Response Description
| Error Code | Message | Description |
|---|---|---|
| 400 | sign can not be empty. | Encryption string is empty |
| 402 | illegal cataid. | Category ID error |
| 400 | ptime is too old. | Timestamp expired |
| 400 | ptime is illegal. | Timestamp format incorrect or exceeds current time by 3 minutes |
| 400 | Could not find user by userid. | User ID does not exist |
| 400 | the sign is not right. | Encryption string is incorrect |
| 402 | illegal query date. | Start date is greater than end date |
| 500 | query failed. | Backend program exception |
| 200 | success | Submission successful |
PHP Request Example
<?php
header("Content-type: text/html; charset=utf-8");
$userid="用户id";
$dr="this_year";
$cataid="1399488884";
$ptime=time()*1000;//13位
$secretkey="填写secretKey";
$str="cataid=".$cataid."&dr=".$dr."&ptime=".$ptime.$secretkey;
$hash=strtoupper(sha1($str));
$url="http://api.polyv.net/v2/cata/$userid/stats-info?ptime=$ptime&sign=$hash&dr=$dr&cataid=$cataid";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
print_r($output);
?>
Signature Rules:
Arrange non-empty request parameters in dictionary order by parameter name, concatenate parameter names and values, append the secret key at the end, and generate a 40-character uppercase SHA1 value as the sign. Example process:
1. Request Parameters
ptime = "1492591990000"
cataid = "1333444444"
format = "json"
2. Arrange Request Parameters in Dictionary Order
cataid = "1333444444"
format = "json"
ptime = "1492591990000"
3. Concatenate String Concatenate parameter names and values, and append the secret key at the end (secret key value: tIQp4ATe9Z), as follows:
cataid=1333444444&format=json&ptime=1492591990000be68715e9455f8d0971a_3tIQp4ATe9Z
4. Generate Signature sign
50BF9B165630A8047EB1D17D95A469CC51FF754E
