取得多個頻道下(聚合查詢結果)的終端分佈資訊
更新時間:2022-09-02 18:08:07
介面URL
https://api.polyv.net/live/v3/channel/statistics/browsers-summary
介面說明
1、接口用于获取多个频道下(聚合查询结果)的终端分布信息
2、接口支持https
支援格式
JSON
請求方式
GET
請求數限制
TRUE
請求參數
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| appId | 是 | string | 從API設定中取得,在直播系統登記的appId |
| timestamp | 是 | long | 目前13位毫秒級時間戳,3分鐘內有效 |
| sign | 是 | String | 簽名,為32位大寫的MD5值,產生簽名的appSecret金鑰作為通訊資料安全的關鍵資訊,嚴禁儲存在用戶端直接使用,所有API都必須透過客戶自己伺服器中轉呼叫POLYV伺服器取得回應資料【詳見簽名產生規則】 |
| channelId | 是 | string | 頻道號,多個頻道以,隔開 |
| startDate | 是 | string | 開始日期格式,yyyy-MM-dd |
| endDate | 是 | string | 結束日期格式,yyyy-MM-dd |
回應成功JSON範例:
{
"code": 200,
"status": "success",
"message": "",
"data": [{
"browser": "Chrome 浏览器",
"count": 69,
"platform": "pc",
"percent": 98.57
},
{
"browser": "IE 11.0 浏览器",
"count": 1,
"platform": "pc",
"percent": 1.43
}]
}
回應失敗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": 403,
"status": "error",
"message": "illegal channel id: 1234567",
"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 | 日期區間內的多個頻道下(聚合查詢結果)的終端分佈資訊 |
Java請求範例
public static void main(String[] args) {
String url = "http://api.polyv.net/live/v3/channel/statistics/browsers-summary;
// 用户对应的appId和加密串
String appId = "xxxxxxxxx";
String appSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
Map<String, String> params = new HashMap<>();
int channelId = 1234567;
String startDate = "2020-08-01";
String endDate = "2020-08-18";
params.put("channelId", String.valueOf(channelId));
params.put("startDate", startDate);
params.put("endDate", endDate);
PolyvTool.setLiveSign(params, appId, appSecret);
// 调用Polyv的httpClient工具类发送请求
String content = HttpClientUtil.getInstance()
.sendHttpGet(url + "?" + PolyvTool.mapJoinNotEncode(params));
System.out.println(content);
}
