接口URL
https://api.polyv.net/v2/video/{userId}/srt/upload
接口说明
(接口调用有频率限制,详细请查看)
上传点播视频字幕接口,改接口会自动检测字幕语言。
返回结果支持格式
form-data
请求方式
POST
请求参数
参数名 | 必选 | 类型及范围 | 说明 |
---|---|---|---|
userId | true | string | 用户id,路径参数 |
ptime | true | string | 当前13位毫秒级时间戳,3分钟内有效 |
sign | true | string | 签名,40位大写的sha1值 |
vid | true | string | 点播视频vid |
title | true | string | 字幕名称 |
file | true | file | 字幕文件,支持utf-8编码 |
asDefault | false | string | 是否作为默认字幕,Y:是,N:否 |
language | false | string | 语言,默认自动检测,支持语言:中文、繁体中文 、英语、日语、韩语、法语、德语、俄语、西班牙语、阿拉伯语、葡萄牙语、其他 |
返回结果
{
"code": 200,
"status": "success",
"message": "success",
"data": null
}
失败返回json
// 时间戳过期:
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
// 文件名称为空
{
"code": 400,
"status": "error",
"message": "title can't be empty",
"data": ""
}
// 文件为空
{
"code": 400,
"status": "error",
"message": "file can't be empty",
"data": ""
}
// 签名报错
{
"code": 400,
"status": "error",
"message": "the sign is not right.",
"data": ""
}
响应参数说明
字段 | 说明 | 类型 | schema |
---|---|---|---|
code | 响应码 | int32 | |
status | 响应状态:success/error/fail | string | |
message | 错误信息说明 | string | |
data | 响应数据 |
响应错误说明
错误代码 | message | 说明 |
---|---|---|
400 | sign can not be empty. | 加密串为空 |
400 | ptime is too old. | 时间戳过期 |
400 | ptime is illegal. | 时间戳参数格式不对或者超过当前时间3分钟 |
400 | Could not find user by userId. | userId不存在 |
400 | the sign is not right. | 签名不正确 |
400 | vid can't be empty | 视频vid为空 |
400 | file can't be empty | 视频文件不能为空 |
400 | title can't be empty | 标题为空 |
400 | language is not support | 不支持的语言 |
PHP请求示例
<?php
$userId="xxxxxx";
$secretkey="xxxxxx";
$url = 'http://api.polyv.net/v2/video/'.$userId.'/srt/upload';
$header = array('Content-type: multipart/form-data');
$data = array(
"ptime" => time()*1000,
"title" => "xxxxx",
"vid" => "xxxxxx_x",
);
ksort($data);
$str='';
foreach ($data as $k => $v) {
$str = $str.$k.'='.$v.'&';
}
$str=substr($str,0,strlen($str)-1);
$str=$str.$secretkey;
$hash=strtoupper(sha1($str));
$data["sign"]=$hash;
$data['file']='@/home/moshunwei/english.srt';
// 请求接口
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$sResult = curl_exec($ch);
if($sError=curl_error($ch)){
die($sError);
}
curl_close($ch);
//打印获得的数据
print_r($sResult);
?>
签名规则:
将非空的请求参数按照参数名字典顺序排列,连接参数名与参数值,并在尾部加上secretkey,生成40位大写SHA1值,作为sign。 以下是示例过程:
1、请求参数为
ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"
format = "json"
2、将请求参数按照参数名字典顺序排列
format = "json"
ptime = "1492591990000"
vid = "382839019131be68715e9455f8d0971a_3"
3、连接字符串
连接参数名与参数值,并在尾部加上secretkey(secretkey的值为tIQp4ATe9Z),如下:
format=json&ptime=1492591990000&vid=382839019131be68715e9455f8d0971a_3tIQp4ATe9Z
4、生成签名sign
50BF9B165630A8047EB1D17D95A469CC51FF754E