Polyv Help Center

Help Center

Get OSS Upload Credentials

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

Interface URL

https://api.polyv.net/live/v3/common/image/get-token

Interface Description

1、接口用于获取上传OSS的凭证
2、接口支持https

Supported Format

JSON

Request Method

GET

Request Limit

TRUE

Request Parameters

Parameter Required Type Description
appId Yes string Obtained from API settings, the appId registered in the live streaming system
timestamp Yes long 13-digit current timestamp
sign Yes String Signature, a 32-character uppercase MD5 value. The appSecret key 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, which relays requests to the POLYV server to obtain response data. See signature generation rules

Successful Response JSON Example:

{
"code": 200,
"status": "success",
"message": "",
"data": {
"accessid": "LTAIjcVf4Pr7yABI",
"signature": "j8VTDUnrHMIfVgkRiyIUrSrI1hg=",
"expire": "1555923547",
"host": "liveimages.videocc.net",
"dir": "uploadimage/20190422/",
"policy": "eyJleHBpcmF0aW9uIjoiMjAxOS0wNC0yMlQwODo1OTowNy45MThaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMzIyMTIyNTQ3MjBdLFsic3RhcnRzLXdpdGgiLCIka2V5IiwidXBsb2FkaW1hZ2UvMjAxOTA0MjIvIl1dfQ=="
}
}

Failed Response JSON Examples:

No appId entered

{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}

Incorrect appId

{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}

Timestamp error

{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}

Signature error

{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}

Field Description

Parameter Description
code Response code: 200 for success, 400 for failure, 401 for signature error, 500 for exception error
status "success" for success, "error" for failure
message Error message when an error occurs
data Relevant credential information on successful response

PHP Request Example

<?php
//引用config.php
include '/srv/http/config.php';
$params = array(
  'appId' => $appId,
  'timestamp' => $timestamp
);

//生成sign
$sign = getSign($params); //详细查看config.php文件的getSign方法
$params['sign'] = $sign;

$url = "https://api.polyv.net/live/v3/common/image/get-token?".http_build_query($params);

$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, $url);
$res = curl_exec($curl);
curl_close($curl);

echo $res;
?>
联系客服,在线咨询