Get Video Cover
API Description
1、通过视频id获取单个视频的封面图片链接
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
API URL
http://api.polyv.net/v2/video/{userid}/get-image
Request Method
GET
API Constraints
The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
The concatenation rule for sign (signature) is: ptime=parameter&t=parameter&vid=parameter, and it is passed along with sign via URL.
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 and must not be stored on the client side. 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, e.g., 1b448be3235552e5fafb16489eb01839_1 |
| t | false | Integer | When set to 1, retrieves the thumbnail of the video cover image |
Example
http://api.polyv.net/v2/video/1b448be323/get-image?vid=1b448be323dec2a7bed6db61bd7d8a77_1&t=1&sign=A722F1E5307046E824C4AA857B8D2B9DEA43A6CA&ptime=1617263701543
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 the image URL 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 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(VodVideoPosterTest.class);
/**
* 获取视频封面
*/
@Test
public void testGetPoster() 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/get-image",userid);
String vid = "1b448be323dec2a7bed6db61bd7d8a77_1";
String t = "1";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("ptime", ptime);
requestMap.put("vid", vid);
requestMap.put("t",t);
//系统只部分参数进行签名
Map<String, String> signMap = new HashMap<>();
signMap.put("ptime", ptime);
signMap.put("vid", vid);
signMap.put("t",t);
requestMap.put("sign", VodSignUtil.getSign(signMap, secretKey));
String response = HttpUtil.get(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": "http://img.videocc.net/uimage/1/1b448be323/7/1b448be323dec2a7bed6db61bd7d8a77_0.jpg"
}
Error Example
{
code: 400,
status: "error",
message: "the sign is not right.",
data: ""
}
