1、通过频道号获取该频道某段时间的直播观看的统计数据
2、接口URL中的{channelId}为频道号
3、接口支持https协议
http://api.polyv.net/live/v2/statistics/{channelId}/summary
http://api.polyv.net/live/v2/statistics/1965681/summary?startDay=2020-1-1&appId=frlr1zazn3&endDay=2020-5-11&sign=311D8B0532DC5BC3F75CE25F4A9EF36A×tamp=1621842602591
强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
private static final Logger log = LoggerFactory.getLogger(ChannelViewDataTest.class);
/**
* 查询频道某段时间的直播观看详情数据
* @throws IOException
*/
@Test
public void testSummary() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String userId = super.userId;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = String.format("http://api.polyv.net/live/v2/statistics/%s/summary","1965681");
String startDay = "2020-1-1";
String endDay = "2020-5-11";
//http 调用逻辑
Map<String,String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp",timestamp);
requestMap.put("startDay",startDay);
requestMap.put("endDay",endDay);
requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.get(url, requestMap);
log.info("测试查询频道某段时间的直播观看详情数据,返回值:{}",response);
//do somethings
}
{
"status":"success",
"result":[
{
"currentDay":"2020-10-20",
"channelId":1965681,
"userId":"1b448be323",
"pcPlayDuration":7,
"pcFlowSize":0,
"pcVideoView":7,
"pcUniqueViewer":1,
"mobilePlayDuration":0,
"mobileFlowSize":0,
"mobileVideoView":0,
"mobileUniqueViewer":0,
"createdTime":1603218100000,
"lastModified":1603218100000,
"creatorId":"1b448be323",
"creatorName":"主账号"
},
{
"currentDay":"2020-10-26",
"channelId":1965681,
"userId":"1b448be323",
"pcPlayDuration":17,
"pcFlowSize":0,
"pcVideoView":12,
"pcUniqueViewer":1,
"mobilePlayDuration":2,
"mobileFlowSize":0,
"mobileVideoView":1,
"mobileUniqueViewer":1,
"createdTime":1603736505000,
"lastModified":1603736505000,
"creatorId":"1b448be323",
"creatorName":"主账号"
},
{
"currentDay":"2020-11-12",
"channelId":1965681,
"userId":"1b448be323",
"pcPlayDuration":1,
"pcFlowSize":0,
"pcVideoView":1,
"pcUniqueViewer":1,
"mobilePlayDuration":0,
"mobileFlowSize":0,
"mobileVideoView":0,
"mobileUniqueViewer":0,
"createdTime":1605205271000,
"lastModified":1605205271000,
"creatorId":"1b448be323",
"creatorName":"主账号"
},
{
"currentDay":"2020-12-03",
"channelId":1965681,
"userId":"1b448be323",
"pcPlayDuration":1,
"pcFlowSize":0,
"pcVideoView":1,
"pcUniqueViewer":1,
"mobilePlayDuration":0,
"mobileFlowSize":0,
"mobileVideoView":0,
"mobileUniqueViewer":0,
"createdTime":1607019680000,
"lastModified":1607019680000,
"creatorId":"1b448be323",
"creatorName":"主账号"
}
]
}
{
"code":"invalid.request",
"msg":"signature error."
}