我試圖從他們的API使用create_video
方法將視頻上傳到Brightcove。他們的所有示例都顯示瞭如何從已從表單提交的圖像中執行此操作。我需要用已經在服務器上的圖像來完成它。我覺得我很接近,但我不斷收到以下錯誤:如何通過PHP和Curl通過API將視頻上傳到Brightcove
{"error": {"name":"RequiredParameterError","message":"create_video requires a filestream or remote asset references","code":303}, "result": null, "id": null}1
這裏是我的代碼:
$data = array(
'method' => "create_video",
'params' => array(
'video' => array(
'name' => $video->filename,
'referenceId' => $video->id,
'shortDescription' => 'Sample video'
),
"token" => $this->config->item('brightcove_write_token'),
"encode_to" => "MP4",
"create_multiple_renditions" => "True",
),
'filename' => $video->filename,
'file' => FCPATH.'assets/uploads/submitted/'.$video->filename
);
$data_string = json_encode($data);
$url = 'http://api.brightcove.com/services/post';
$fields = array(
'json' => $data_string
);
//url-ify the data for the POST
$fields_string='';
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//execute post
$result = curl_exec($ch);
感謝您的回答我仍然得到相同的錯誤,雖然 – geoffs3310
我找不到他們的API文檔,所以不知道如何繼續。 JSON編碼的數據字符串實際上會使上傳字段不起作用(我只是注意到,我發佈我的答案後)。他們的API是否希望你提供一個URL到他們下載的視頻? – drew010
這是API文檔的URL http://docs.brightcove.com/en/video-cloud/media/references/reference.html#Video_Write – geoffs3310