Query Video Authorization Playback Switch
Updated: 2025-01-14 16:08:24
Interface Description
1、通过视频id查询单个视频的授权播放开关状态
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
Interface URL
http://api.polyv.net/v2/video/{userid}/authplay-status
Request Method
GET
Interface Constraints
- The interface supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. Interface calls have frequency limits. See details
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| ptime | true | Long | Current time in milliseconds timestamp, valid for 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 on the client side for direct use. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See signature generation rules |
| vid | true | String | Video ID |
Example
http://api.polyv.net/v2/video/1b448be323/authplay-status?vid=1b448be32303e4922a8f70d6b48220ae_1&sign=CFB9913E9B805681EF575B9BEE4C381888DA613F&ptime=1617763189875
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, when code is 400 or 500, provides auxiliary error reason |
| data | Object | Returns switch status on success, returns empty on failure 0: Switch off 1: Switch on |
Error Code List
| Error Code | message | Description |
|---|---|---|
| 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. | |
| 403 | Video not found under user's videos. |
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 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 pools.
private static final Logger log = LoggerFactory.getLogger(VodPlayAuthTest.class);
/**
* 查询视频的授权播放开关
* @throws Exception
* @throws NoSuchAlgorithmException
*/
@Test
public void testGetPlayAuthSetting() 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 vid = "1b448be32303e4922a8f70d6b48220ae_1";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("ptime", ptime);
requestMap.put("vid", vid);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.get(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": 1
}
Error Example
Timestamp expired
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
