1、获取直播间观众统计数据
2、接口支持https协议
http://api.polyv.net/live/v3/channel/statistics/listViewLogs
http://api.polyv.net/live/v3/channel/statistics/listViewLogs?appId=f2zgpeyx00×tamp=1638179488464&sign=C55D7D032E3FFB28324442C4DF74C6B2&startTime=1633017600000&endTime=1638288000000&channelId=2000007&pageSize=10&pageNumber=1
强烈建议您使用直播Java SDK完成API的功能对接,直播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
private static final Logger log = LoggerFactory.getLogger(GetCdnViewLog.class);
/**
* 获取直播间观众统计数据
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testGetCdnViewLog() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String userId = super.userId;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v3/channel/statistics/listViewLogs";
String channelId = "2377623";
long startTime = 1633017600000L;
long endTime = 1635696000000L;
int pageSize = 1;
int pageNumber = 10;
//http 调用逻辑
Map<String,String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp",timestamp);
requestMap.put("channelId",channelId);
requestMap.put("startTime",String.valueOf(startTime));
requestMap.put("endTime",String.valueOf(endTime));
requestMap.put("pageSize",String.valueOf(pageSize));
requestMap.put("startTime",String.valueOf());
requestMap.put("pageNumber",String.valueOf(pageNumber));
requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.get(url, requestMap);
log.info("测试获取直播间观众统计数据返回值:{}",response);
//do somethings
}
{
"code": 200,
"status": "success",
"message": "",
"data": {
"pageSize": 10,
"pageNumber": 1,
"totalItems": 2,
"contents": [{
"playDuration": 27,
"stayDuration": 30,
"param1": "",
"param2": "",
"param3": "vod",
"createdTime": 1635439162000,
"ipAddress": "116.23.155.239",
"address": "广东广州",
"referer": "https://console.polyv.net/live/#/channel/2000007/video-library",
"browser": "Chrome 9",
"sessionId": "",
"province": "广东",
"city": "广州",
"ptype": 0,
"originSessionId": ""
}, {
"playDuration": 179,
"stayDuration": 180,
"param1": "1634632927097",
"param2": "直播观众/21234",
"param3": "live",
"createdTime": 1634633045000,
"ipAddress": "61.144.145.78",
"address": "广东广州",
"referer": "https://live.polyv.cn/watch/2000007",
"browser": "Chrome 9",
"sessionId": "g3ffzv8bkj",
"province": "广东",
"city": "广州",
"ptype": 0,
"originSessionId": "g3ffzv8bkj"
}],
"limit": 2,
"endRow": 2,
"totalPages": 1,
"nextPageNumber": 1,
"startRow": 1,
"firstPage": true,
"lastPage": true,
"prePageNumber": 1,
"offset": 0
}
}
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}