Set Playback Domain Restriction Rules
Updated: 2025-01-14 16:10:55
API Description
1、设置播放域名的限制规则
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
API URL
http://api.polyv.net/v2/play/{userid}/domain
Request Method
POST
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended to ensure 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 retrieve response data. See Signature Generation Rules |
| settingType | true | Integer | Domain restriction type 0: No domain restriction 1: Blacklist 2: Whitelist 3: Composite whitelist and blacklist restriction (whitelist checked first, then blacklist) |
| host | false | String | Domain configuration, multiple domains separated by commas. This parameter is only valid when settingType is 1 or 2 and is not null. Maximum of 5 domains allowed. |
Example
http://api.polyv.net/v2/play/1b448be323/domain
Form Parameters:
host=www.baidu.com&sign=0DD842813DBE070805BFB6A806F3A813705DFB86&ptime=1620635007028&settingType=2
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, provides error details when code is 400 or 500 |
| data | String | Returns "Modification successful" on success, empty on failure |
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 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(VodVideoDomainRestrictTest.class);
/**
* 设置播放域名限制规则
*/
@Test
public void testSetDomainRestrictRule() throws Exception, NoSuchAlgorithmException {
//业务参数
String url = "http://v.polyv.net/uc/services/rest?method=saveHostSetting_type";
String writeToken = super.writeToken;
String settingType = "2";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("writetoken", writeToken);
requestMap.put("settingType", settingType);
String response = HttpUtil.postFormBody(url, requestMap);
log.debug("测试设置播放域名限制规则,{}", response);
//do somethings
}
Response Example
For global error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"message": "success",
"data": "修改成功."
}
Error Example
Incorrect Signature
{
"code":400,
"status":"error",
"message":"the sign is not right",
"data":""
}
Timestamp Expired
{
"code":400,
"status":"error",
"message":"ptime is too old.",
"data":""
}
