Polyv Help Center

Help Center

Modify Video Authorization Playback Switch

Updated: 2025-01-14 16:08:47

API Description

1、通过视频id修改单个或多个视频的授权播放开关状态
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议

API URL

http://api.polyv.net/v2/video/{userid}/authplay-status

Online API Call

Request Method

POST

API Constraints

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

Request Parameter Description

Parameter Required Type Description
ptime true Long Current time in milliseconds timestamp, 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 not be stored directly on the client. All APIs must be relayed through the customer's own server to call the POLYV server for response data. See signature generation rules
vids true String Video IDs, separated by commas for multiple IDs
playauth false Integer Whether the authorization playback switch is enabled. Default is 1 (enabled).
0: Disabled
1: Enabled

Example

http://api.polyv.net/v2/video/1B448BE323/authplay-status

Form Parameters:

vids=1b448be32303e4922a8f70d6b48220ae_1,1b448be3239482977934f099f2ceaa0a_1&sign=F3A49012205FB15B405B60F54B5A7097C3839571&ptime=1617764598784&playauth=0

Response Parameter Description

Parameter Type Description
code Integer Response status code. 200 indicates success, non-200 indicates failure. See global error description
status String Response status text
message String Response description. When code is 400 or 500, provides additional error details
data Object Returns the number of successfully modified items on success, returns empty on failure

Error Code List

Error Code message Description
400 sign can not be empty. Signature cannot be empty
400 ptime is too old. Timestamp expired
400 ptime is illegal. ptime exceeds current time by 3 minutes
400 Could not find user by userid. Incorrect userid
400 the sign is not right. Incorrect signature
401 vid is empty.

Java Request Example

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

It is strongly recommended to use the VOD Java SDK for API functionality 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(VodPlayAuthTest.class);
/**
 * 修改视频的授权播放开关
 * @throws Exception
 * @throws NoSuchAlgorithmException
 */
@Test
public void testUpdatePlayAuthSetting() 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/video/%S/authplay-status", userId);
    String vids = "1b448be32303e4922a8f70d6b48220ae_1,1b448be3239482977934f099f2ceaa0a_1";
    String playauth = String.valueOf(0);
    
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("ptime", ptime);
    requestMap.put("vids", vids);
    requestMap.put("playauth", playauth);
    requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
    
    String response = HttpUtil.postFormBody(url, requestMap);
    log.debug("测试修改视频的授权播放开关,{}", response);
    //do somethings
    
}

Response Example

For global system error descriptions, see Global Error Description

Success Example

{
    "code": 200,
    "status": "success",
    "message": "success",
    "data": 2
}

Error Example

Timestamp Expired

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