查询播放量统计
接口描述
1、查询视频播放量在不同终端的统计数据,从播放行为产生到数据可查询的间隔时间为1~2小时
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
接口URL
http://api.polyv.net/v2/videoview/{userid}
请求方式
GET
接口约束
1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看
2、请求参数period(显示周期)的值受限于dr的值,当dr的值为today,yesterday,this_week,last_week,7days时,period只能为daily;当dr的值为this_month,last_month时,period只能为daily或者weekly
请求参数描述
ptime
true
Long
当前时间的毫秒级时间戳,3分钟内有效
sign
true
String
签名,为40位大写的SHA1值,生成签名的secretkey密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据
【详见签名生成规则】
vid
false
String
视频id,不填会查所有视频的播放量统计数据
dr
false
String
时间段,不传默认为7days today:今天 yesterday:昨天 this_week:本周 last_week:上周 7days:最近7天 this_month:本月 last_month:上个月 this_year:今年 last_year:去年
period
false
String
显示周期,不传默认为daily daily:按日显示 weekly:按周显示 monthly:按月显示
示例
http://api.polyv.net/v2/videoview/1b448be323?vid=1b448be32395861bacc794ca59e8f306_1&sign=AD7527B17D2F2BE5E740F9D3357B7F80231837CE&userId=1b448be323&ptime=1618215907432
响应参数描述
currentTime
String
当前日期,格式为:yyyy-MM-dd
pcVideoView
Integer
pc端播放量
mobileVideoView
Integer
移动端播放量
返回错误代码列表
400
sign can not be empty.
加密串为空
400
ptime is too old.
时间戳过期
400
ptime is illegal.
时间戳参数格式不对或者超过当前时间3分钟
400
Could not find user by userid.
userid不存在
400
the sign is not right.
加密串不正确
401
illegal vid.
vid格式不正确,正确vid格式前面一段是userid
402
illegal period.
period的值非法,请看请求参数里period的限制内容
500
query failed.
后台程序抛异常
Java请求示例
快速接入基础代码请下载相关依赖源码, 点击下载源代码 ,下载后加入到自己的源码工程中即可。测试用例中的HttpUtil.java 和 VodSignUtil.java 都包含在下载文件中。
强烈建议您使用点播Java SDK完成API的功能对接,点播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
private static final Logger log = LoggerFactory.getLogger(VodStatisticsTest.class);
/**
* 查询播放量统计
* @throws Exception
* @throws NoSuchAlgorithmException
*/
@Test
public void testGetPlaytimes() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userId = super.userId;
String ptime = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/v2/videoview/" + userId;
String vid = "1b448be32395861bacc794ca59e8f306_1";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("userId", userId);
requestMap.put("ptime", ptime);
requestMap.put("vid", vid);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.get(url, requestMap);
log.debug("测试查询播放量统计,{}", response);
//do somethings
}
响应示例
系统全局错误说明详见全局错误说明
成功示例
{
"code":200,
"status":"success",
"message":"success",
"data":[
{
"currentTime":"2021-04-06",
"pcVideoView":0,
"mobileVideoView":0
},
{
"currentTime":"2021-04-07",
"pcVideoView":0,
"mobileVideoView":0
},
{
"currentTime":"2021-04-08",
"pcVideoView":0,
"mobileVideoView":0
},
{
"currentTime":"2021-04-09",
"pcVideoView":0,
"mobileVideoView":0
},
{
"currentTime":"2021-04-10",
"pcVideoView":0,
"mobileVideoView":0
},
{
"currentTime":"2021-04-11",
"pcVideoView":0,
"mobileVideoView":0
},
{
"currentTime":"2021-04-12",
"pcVideoView":0,
"mobileVideoView":0
}
]
}
异常示例
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
Last updated
Was this helpful?