private static final Logger log = LoggerFactory.getLogger(VodSubAccountTest.class);
/**
* 获取视频播放凭证
* @throws Exception
* @throws NoSuchAlgorithmException
*/
@Test
public void testCreateSubToken() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String ts = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://hls.videocc.net/service/v2/token/create-child";
String videoId = "1b448be32370f4822ac40fd926112a66_1";
String viewerId = "ovtl9t_RxnrTdqkXqkT5Q5lnxp2A";
String viewerIp = "59.41.20.74";
String viewerName = "观看者昵称";
String expires = "10000";
String disposable = "true";
String isWXa = "1";
String extraParams = "ddd";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("videoId", videoId);
requestMap.put("ts", ts);
requestMap.put("viewerId", viewerId);
requestMap.put("viewerIp", viewerIp);
requestMap.put("viewerName", viewerName);
requestMap.put("expires", expires);
requestMap.put("disposable", disposable);
requestMap.put("iswxa", isWXa);
requestMap.put("extraParams", extraParams);
//用md5进行签名,使用子账号的secretKey签名
requestMap.put("sign", VodSignUtil.getSignMd5(requestMap, appSecret));
String response = HttpUtil.postFormBody(url, requestMap);
log.debug("测试获取视频播放凭证,{}", response);
//do somethings
}