1、获取频道观看日志
2、接口URL中的{channelId}为频道号
3、接口支持https协议
http://api.polyv.net/live/v1/statistics/{channelId}/viewlog
http://api.polyv.net/live/v1/statistics/1965681/viewlog?currentDay=2021-1-20&appId=frlr1zazn3&sign=B4A33B092F5E5B9283C9D8308E10B868&userId=1b448be323¶m1=1b448be323×tamp=1621842550515
强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
private static final Logger log = LoggerFactory.getLogger(ChannelViewDataTest.class);
/**
* 测试查询频道直播观看详情数据
* @throws IOException
*/
@Test
public void testViewlog() 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/v1/statistics/%s/viewlog","1965681");
String currentDay = "2021-1-20";
String param1 = "1b448be323";
//http 调用逻辑
Map<String,String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp",timestamp);
requestMap.put("currentDay",currentDay);
requestMap.put("userId", userId);
requestMap.put("param1",param1);
requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.get(url, requestMap);
log.info("测试查询频道直播观看详情数据,返回值:{}",response);
//do somethings
}
{
"status":"success",
"result":[
{
"playId":"1611137360114X1320926",
"userId":"1b448be323",
"channelId":1965681,
"playDuration":182,
"stayDuration":190,
"flowSize":0,
"sessionId":"fv3ma84e63",
"param1":"1b448be323",
"param2":"管理员",
"param3":"live",
"param4":"",
"param5":"",
"ipAddress":"118.249.213.240",
"country":"中国",
"province":"湖南",
"city":"长沙",
"isp":"湖南电信",
"referer":"https://live.polyv.net/#/channel/1965681/monitoring",
"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0",
"operatingSystem":"Windows",
"browser":"Firefox 8",
"isMobile":"N",
"currentDay":"2021-01-20",
"createdTime":1611137461000,
"lastModified":1611148800000,
"ptype":0
},
{
"playId":"1611127231433X1037457",
"userId":"1b448be323",
"channelId":1965681,
"playDuration":154,
"stayDuration":160,
"flowSize":0,
"sessionId":"fv3hmq3qml",
"param1":"1b448be323",
"param2":"管理员",
"param3":"live",
"param4":"",
"param5":"",
"ipAddress":"118.249.213.240",
"country":"中国",
"province":"湖南",
"city":"长沙",
"isp":"湖南电信",
"referer":"https://live.polyv.net/#/channel/1965681/monitoring",
"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0",
"operatingSystem":"Windows",
"browser":"Firefox 8",
"isMobile":"N",
"currentDay":"2021-01-20",
"createdTime":1611127282000,
"lastModified":1611138733000,
"ptype":0
}
]
}
{
"code":"invalid.request",
"msg":"signature error."
}