Polyv Help Center

Help Center

Modify Account Encryption Settings

Updated: 2025-01-14 16:07:28

API Description

1、修改用户账号下的加密设置
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议

API URL

http://api.polyv.net/v2/setting/{userid}/set-playsafe

Online API Call

Request Method

POST

API Constraints

  1. The API supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. API calls have frequency limits. See details

Request Parameter Description

Parameter Required Type Description
ptime true Long Current time in milliseconds, valid within 3 minutes
sign true String Signature, a 40-character uppercase SHA1 value. The secretkey used to generate the signature is critical for communication data security. It must never be saved or used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server and obtain response data. See signature generation rules
encrypt true String Whether to enable encryption (only valid for newly uploaded videos)
1: Enable
0: Disable
hlslevel true String Video encryption settings
open: Non-encrypted authorization
web: WEB authorization
app: APP authorization
wxa_app: Mini program authorization

Example

http://api.polyv.net/v2/setting/1b448be323/set-playsafe

Form parameters:

encrypt=1&sign=54A8A76BBE7FE9E00DA7F9DF425CE5C2C04F2E5A&ptime=1617701784209&hlslevel=app

Response Parameter Description

Parameter Type Description
code Integer Response status code, 200 for success, non-200 for failure See global error description
status String Response status text
message String Response description, auxiliary error reason when code is 400 or 500
data Object Returns account encryption information on success See data field description

data Field Description

Parameter Type Description
encrypt String Whether encryption is enabled
1: Enable
0: Disable
hlslevel String Video encryption settings
open: Non-encrypted authorization
web: WEB authorization
app: APP authorization
wxa_app: Mini program authorization
Error Code List
Error Code message Description
400 sign can not be empty. Encryption string is empty
400 ptime is too old. Timestamp expired
400 ptime is illegal. Timestamp parameter format is incorrect or exceeds current time by 3 minutes
400 Could not find user by userid. userid does not exist
400 the sign is not right. Encryption string is incorrect
400 hlslevel error Encryption setting (hlslevel) is not a valid value

Java Request Example

For quick integration of basic code, please download the relevant dependency source code. Click to download source code. After downloading, add it to your own source project. HttpUtil.java and VodSignUtil.java in the test cases are included in the download file.

It is strongly recommended to use the VOD Java SDK for API integration. The VOD Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pooling.

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("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
}

Response Example

For system global error descriptions, see Global Error Description

Success Example

{
    "code": 200,
    "status": "success",
    "message": "success",
    "data": {
        "encrypt": "1",
        "hlslevel": "app"
    }
}

Error Example

 {
    "code": 400,
    "status": "error",
    "message": "ptime is too old.",
    "data": ""
}
联系客服,在线咨询