修改账号的加密设置
接口描述
1、修改用户账号下的加密设置
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
接口URL
http://api.polyv.net/v2/setting/{userid}/set-playsafe
请求方式
POST
接口约束
1、接口同时支持HTTP 、HTTPS ,建议使用HTTPS 确保接口安全,接口调用有频率限制,详细请查看
请求参数描述
ptime
true
Long
当前时间的毫秒级时间戳,3分钟内有效
sign
true
String
签名,为40位大写的SHA1值,生成签名的secretkey密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据
【详见签名生成规则】
encrypt
true
String
是否开启加密(仅对新上传视频有效) 1:开启 0:关闭
hlslevel
true
String
视频加密设置 open: 非加密授权 web: WEB授权 app: APP授权 wxa_app:小程序授权
示例
http://api.polyv.net/v2/setting/1b448be323/set-playsafe
表单参数:
encrypt=1&sign=54A8A76BBE7FE9E00DA7F9DF425CE5C2C04F2E5A&userid=1b448be323&ptime=1617701784209&hlslevel=app
响应参数描述
data字段说明
encrypt
String
是否开启加密 1:开启 0:关闭
hlslevel
String
视频加密设置 open: 非加密授权 web: WEB授权 app: APP授权 wxa_app:小程序授权
返回错误代码列表
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.
加密串不正确
400
hlslevel error
加密设置(hlslevel)非有效值
Java请求示例
快速接入基础代码请下载相关依赖源码, 点击下载源代码 ,下载后加入到自己的源码工程中即可。测试用例中的HttpUtil.java 和 VodSignUtil.java 都包含在下载文件中。
强烈建议您使用点播Java SDK完成API的功能对接,点播Java SDK 对API调用逻辑、异常处理、数据签名、HTTP请求线程池进行了统一封装和优化。
private static final Logger log = LoggerFactory.getLogger(VodVideoEncryptionTest.class);
/**
* 设置账号加密设置
*/
@Test
public void testSetPlaysafe() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userId = super.userId;
String ptime = String.valueOf(System.currentTimeMillis());
//业务参数
String url = String.format("http://api.polyv.net/v2/setting/%s/set-playsafe", userId);
Map<String, String> requestMap = new HashMap<>();
requestMap.put("userid", userId);
requestMap.put("ptime", ptime);
requestMap.put("encrypt", "1");
requestMap.put("hlslevel", "app");
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.postFormBody(url, requestMap);
log.debug("测试设置账号加密设置,{}", response);
//do somethings
}
响应示例
系统全局错误说明详见全局错误说明
成功示例
{
"code": 200,
"status": "success",
"message": "success",
"data": {
"encrypt": "1",
"hlslevel": "app"
}
}
异常示例
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
Last updated
Was this helpful?