批量获取点播视频完成度
更新时间:2022-05-16 10:08:41
接口URL
https://api.polyv.net/v2/video/engagement/{userId}/getList
接口说明
支持批量分页获取视频观看完成度
支持https
支持格式
JSON
请求方式
POST,GET
请求数限制
TRUE
请求参数
返回结果
{
"code": 200,
"status": "success",
"message": "success",
"data": {
"pageSize": 20,
"pageNumber": 1,
"totalItems": 1,
"contents": [
{
"vid": "ee7fe7fbdadafe381e8e100669144e51_e",
"viewerId": "1111",
"watchPercentage": 0.05
}
]
}
}
请求失败返回json示例
// 签名错误
{
"code": 400,
"status": "error",
"message": "the sign is not right.",
"data": ""
}
// 类型错误
{
"code": 400,
"status": "error",
"message": "field type error",
"data": ""
}
// ...
字段说明
Java示例代码
public class Test {
public static void main(String[] args) throws Exception {
String userId = "ee7fe7fbda";
String secretkey = "2owGBAZsAY";
String url = "https://api.polyv.net/v2/video/engagement/%s/getList";
Map<String, String> maps = new HashMap<>();
maps.put("field", "viewer");
maps.put("fieldValue", "1111");
maps.put("filterValue", "");
maps.put("sign", getSign(maps, secretkey));
url += "?" + buildUrl(maps);
url = String.format(url, userId);
HttpClient client = new HttpClient();
GetMethod getMethod = new GetMethod(url);
client.executeMethod(getMethod);
System.out.println(url);
System.out.println(getMethod.getResponseBodyAsString());
}
public static String buildUrl(Map<String, String> maps) {
List<String> tmp = new ArrayList<>();
for (Map.Entry<String, String> key : maps.entrySet()) {
tmp.add(key.getKey() + "=" + key.getValue());
}
return String.join("&", tmp);
}
}