查询频道直播观看详情数据
接口描述
1、获取频道观看日志
2、接口URL中的{channelId}为频道号
3、接口支持https协议
接口URL
http://api.polyv.net/live/v1/statistics/{channelId}/viewlog
请求方式
GET
接口约束
1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看
2、不支持已删除频道进行数据查询
请求参数描述
示例
http://api.polyv.net/live/v1/statistics/1965681/viewlog?currentDay=2021-1-20&appId=frlr1zazn3&sign=B4A33B092F5E5B9283C9D8308E10B868&userId=1b448be323¶m1=1b448be323×tamp=1621842550515
响应参数描述
status
String
状态值
playId
String
表示此次播放动作的ID
userId
String
直播账号ID
channelId
String
频道号
playDuration
Integer
播放时长,单位:秒
stayDuration
Integer
停留时长,单位:秒
flowSize
Long
流量大小,单位:bytes
sessionId
String
直播的场次ID
param1
String
使用POLYV观看页的观众ID
param2
String
使用POLYV观看页的观众昵称
param3
String
观看日志类型,默认为live vod:观看回放 live:直播
param4
String
POLYV系统参数
param5
String
POLYV系统参数
ipAddress
String
IP地址
country
String
国家
province
String
省份
city
String
城市
isp
String
ISP运营商
referer
String
播放视频页面地址
userAgent
String
用户设备
operatingSystem
String
操作系统
browser
String
浏览器
isMobile
String
是否为移动端
currentDay
String
查询日期,格式:yyyy-MM-dd
ptype
Integer
0 或者不传:普通直播 1:超低延迟直播 rts (已经没有在使用) 2:PRTC直播(无延迟)
firstActiveTime
Long
进入时间,13位毫秒级时间戳
lastActiveTime
Long
退出时间,13位毫秒级时间戳
createdTime
Long
数据入库时间,13位毫秒级时间戳
lastModified
Long
数据最后修改时间,13位毫秒级时间戳
Java请求示例
快速接入基础代码请下载相关依赖源码, 点击下载源代码 ,下载后加入到自己的源码工程中即可。测试用例中的HttpUtil.java 和 LiveSignUtil.java 都包含在下载文件中。
强烈建议您使用直播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."
}
Last updated
Was this helpful?