Polyv Help Center

Help Center

Get Video Temporary Link

Updated: 2022-09-02 18:08:07

API Description

1、通过子账号id和视频id,获取视频临时链接
2、接口支持https协议

API URL

http://api.polyv.net/v3/video/get-tmp-access-url

Request Method

POST

API Constraints

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

Request Parameters

Parameter Required Type Description
appId true String POLYV VOD sub-account appId. Retrieval path: POLYV VOD backend -> Settings -> Account Management
timestamp true Long Current time in milliseconds, valid for 3 minutes
sign true String Signature, 32-character uppercase MD5 value See MD5 signature generation rules
vid true String Video ID, e.g.:
"1b448be32370f4822ac40fd926112a66_1";
Retrieval path: POLYV VOD backend -> Video List;
Can also be obtained from Upload Video;

Example

http://api.polyv.net/v3/video/get-tmp-access-url

Form Parameters:

vid=1b448be32370f4822ac40fd926112a66_1&appId=a0Wmol5EwX&sign=197679CCF105DD80E0378BEF75993D31&timestamp=1617950661602

Response Parameters

Parameter Type Description
code Integer Response status code, 200 for success, non-200 for failure See global error description
status String Response status text
requestId String Business request ID for troubleshooting on client/server side
error Object Error details returned on failure [See error field description](/vod/api/sub_account/sub_move_video.md?id=error字段说明], empty on success
data Object Empty on failure

Error Field Description

Field Type Description
code Integer Error code
desc String Error description See global error description

Java Request Example

For quick integration, please download the relevant dependency source code. Click to download source code. Add it to your project after downloading. The HttpUtil.java and VodSignUtil.java in the test cases are included in the download file.

private static final Logger log = LoggerFactory.getLogger(VodSubAccountTest.class);

/**
 * 获取视频临时链接
 * @throws Exception
 * @throws NoSuchAlgorithmException
 */
@Test
public void testGetTmpAccessUrl() throws Exception, NoSuchAlgorithmException {
        //公共参数,填写自己的实际参数
        String appId = super.appId;
        String appSecret = super.appSecret;
        String timestamp = String.valueOf(System.currentTimeMillis());

        //业务参数
        String url = "http://api.polyv.net/v3/video/get-tmp-access-url";
        String vid = "1b448be32370f4822ac40fd926112a66_1";

        Map<String, String> requestMap = new HashMap<>();
        requestMap.put("appId", appId);
        requestMap.put("timestamp", timestamp);
        requestMap.put("vid", vid);

        //用md5进行签名,使用子账号的secretKey签名
        requestMap.put("sign", VodSignUtil.getSignMd5(requestMap, appSecret));
        String response = HttpUtil.postFormBody(url, requestMap);
        log.debug("测试获取视频临时链接,{}", response);
        //do somethings
}

Response Example

For global error descriptions, see Global Error Description

Success Example

{
    "requestId": "8faa1225-111d-401c-84c8-b011dd8950a6", 
    "code": 200, 
    "status": "success", 
    "error": null, 
    "data": {
        "accessUrl": "https://mpv.videocc.net/1b448be3/6/1b448be32370f4822ac40fd926112a66_1.mp4"
    }
}

Error Example

{
    "requestId": "e7544473-250a-40eb-b53b-8768195617e0", 
    "code": 403, 
    "status": "error", 
    "error": {
        "code": 104, 
        "desc": "invalid signature"
    }, 
    "data": null
}
联系客服,在线咨询