|
@@ -152,18 +152,48 @@ public class PolyvVideoServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVi
|
|
|
long ts = System.currentTimeMillis(); // 时间戳
|
|
long ts = System.currentTimeMillis(); // 时间戳
|
|
|
String extraParams = "HTML5"; // 自定义扩展参数
|
|
String extraParams = "HTML5"; // 自定义扩展参数
|
|
|
boolean disposable = false; // true 表示 token 仅一次有效。false 则表示在有效期内可以多次验证。默认为 false。
|
|
boolean disposable = false; // true 表示 token 仅一次有效。false 则表示在有效期内可以多次验证。默认为 false。
|
|
|
-
|
|
|
|
|
|
|
+ String iswxa = "1";
|
|
|
/* 将参数 userId、secretkey、videoId、ts、viewerIp、viewerIp、viewerId、viewerName、extraParams按照ASCKII升序 key + value + key + value ... +value 拼接
|
|
/* 将参数 userId、secretkey、videoId、ts、viewerIp、viewerIp、viewerId、viewerName、extraParams按照ASCKII升序 key + value + key + value ... +value 拼接
|
|
|
*/
|
|
*/
|
|
|
- String concated = "extraParams" + extraParams + "ts" + ts + "userId" + userId + "videoId" + videoId + "viewerId" + viewerId ;
|
|
|
|
|
|
|
+ String concated = "extraParams" + extraParams + "ts" + ts + "userId" + userId + "videoId" + videoId + "viewerId" + viewerId ;
|
|
|
// 首尾加上secretkey值
|
|
// 首尾加上secretkey值
|
|
|
String plain = secretkey + concated + secretkey;
|
|
String plain = secretkey + concated + secretkey;
|
|
|
// 取大写MD5,可自行选择md5库
|
|
// 取大写MD5,可自行选择md5库
|
|
|
String sign = md5Hex(plain).toUpperCase();
|
|
String sign = md5Hex(plain).toUpperCase();
|
|
|
|
|
+
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("sign",sign);
|
|
map.put("sign",sign);
|
|
|
map.put("ts",ts);
|
|
map.put("ts",ts);
|
|
|
return map;
|
|
return map;
|
|
|
|
|
+
|
|
|
|
|
+ /* String url = "https://hls.videocc.net/service/v1/token";
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
|
|
+ params.put("userId", userId);
|
|
|
|
|
+ params.put("videoId", videoId);
|
|
|
|
|
+ params.put("ts", String.valueOf(ts));
|
|
|
|
|
+ params.put("extraParams", extraParams);
|
|
|
|
|
+ params.put("viewerId", viewerId);
|
|
|
|
|
+ params.put("sign", sign);
|
|
|
|
|
+ params.put("iswxa", iswxa);
|
|
|
|
|
+
|
|
|
|
|
+ // 可自行选择http客户端
|
|
|
|
|
+ String response = HttpUtils.postFormBody(url, params);
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ //解析json
|
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
+ TokenResponse tokenResponse = objectMapper.readValue(response, TokenResponse.class);
|
|
|
|
|
+ // 响应代码,200为成功,403为ts过期或签名错误,400为参数错误(例如缺少 userId 或 videoId)
|
|
|
|
|
+ if (tokenResponse.getCode() == 200) {
|
|
|
|
|
+ Map data = (Map) tokenResponse.getData();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;*/
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|