【发布时间】:2016-02-02 05:09:36
【问题描述】:
我正在尝试使用他们 API 中的 create_video 方法将视频上传到 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);
【问题讨论】:
标签: php curl brightcove