# 点播视频CDN刷新和预热

### 接口URL

```
https://api.polyv.net/v2/video/refresh-cdn-cache
```

### 接口说明

```
1. 点播视频CDN刷新预热，目前仅支持预热点播zip文件
2. 提交任务后，需 5-10 分钟左右才能生效
3. 同一个用户，每天最多刷新预热 2000 个文件
```

### 请求方式

```html
1. 支持POST请求，参数需放在请求体中，并以form表单的形式提交
2. Content-Type: application/x-www-form-urlencoded
```

### 请求参数

| 参数名                | 必选   | 类型及范围  | 说明                                                                                                                       |
| ------------------ | ---- | ------ | ------------------------------------------------------------------------------------------------------------------------ |
| userid             | true | string | 用户ID                                                                                                                     |
| ptime              | true | long   | 13位当前时间的毫秒级时间戳                                                                                                           |
| sign               | true | String | 签名，为40位大写的SHA1值【详见[签名生成规则](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/buildSign/README.md)】 |
| action             | true | string | 执行操作，预热："push"                                                                                                           |
| fileType           | true | string | 文件类型，点播视频zip文件："zip"                                                                                                     |
| videos             | true | array  | 视频信息数组，格式为json字符串，**每次请求的数量不能超过100个**                                                                                    |
| videos\[0].vid     | true | string | 视频ID                                                                                                                     |
| videos\[0].brIndex | true | int    | 码率序号，1：流畅，2：高清，3：超清                                                                                                      |
| ### videos 参数示例    |      |        |                                                                                                                          |
| \`\`\`json         |      |        |                                                                                                                          |
| \[                 |      |        |                                                                                                                          |

```
{
"vid": "e6b23c6f513fbe025b94efdd10d7ab47_e",
"brIndex": 1
},
{
"vid": "e6b23c6f513fbe025b94efdd10d7ab47_e",
"brIndex": 2
},
{
"vid": "e6b23c6f513fbe025b94efdd10d7ab47_e",
"brIndex": 3
}
```

]

````

### 返回结果

### JSON示例

```json
上传成功返回示例
{
	"code": 200,
	"status": "success",
	"message": "success",
	"data": {
		"taskId": "b3ad461ef1df4afc9340427767968a4c"
	}
}

````

### 请求失败返回json示例

```json
时间戳过期
{
	"code": 400,
	"status": "error",
	"message": "ptime is too old",
	"data": null
}
```

```json
签名不正确
{
	"code": 400,
	"status": "error",
	"message": "the sign is not right.",
	"data": null
}
```

```json
提交的vid中存在不合法值
{
	"code": 400,
	"status": "error",
	"message": "illeagal vid",
	"data": null
}
```

```json
每次提交不能超过100个文件
{
	"code": 400,
	"status": "error",
	"message": "can't submit more than 100 files",
	"data": null
}
```

```json
码率不存在
{
	"code": 400,
	"status": "error",
	"message": "bitrate does not exist",
	"data": null
}
```

```json
每天不能提交超过2000个文件
{
	"code": 400,
	"status": "error",
	"message": "can't submit more than 2000 files one day",
	"data": null
}
```

### 字段说明

| 字段                                  | 说明      |
| ----------------------------------- | ------- |
| code                                | 请求返回状态码 |
| status                              | 请求返回状态  |
| message                             | 请求返回信息  |
| data                                | 返回数据    |
| data.taskId                         | 任务ID    |
| ### java请求示例                        |         |
| \`\`\`java                          |         |
| public void testRefreshCdnCache() { |         |

```
    String url = "https://api.polyv.net/v2/video/refresh-cdn-cache";
	String userid = "xxxxxxx";
    String vid = "xxxxxxxxxxxxxxxxxxxx";
	String secretkey = "xxxxxxx";
	String videos = "[{\"vid\": \"e6b23c6f513fbe025b94efdd10d7ab47_e\",\"brIndex\": 1}]";
	long ptime = System.currentTimeMillis();

    Map<String, String> params = new HashMap<>();
	params.put("ptime", String.valueOf(ptime));
	params.put("userid", userid);
	params.put("videos", videos);
	params.put("action", "push");
	params.put("fileType", "zip");
	params.put("sign", getSign(params, secretkey));
    String content = HttpClientUtil.getInstance().sendHttpPost(url, params);
    System.out.println(content);
```

}

```



```
