要将视频上传到 vimeo,我们必须使用带有二进制数据的 put 请求,如 文档中所示。我试图从php curl lib
我的代码如下:
$params = array_merge($params, array(
'client_id' => $this->_consumer_key,
'file_data' => '@'.$file_path // don't include the file in the signature
));
$file_path ="/a.mp4";
$fp = fopen($file_path, 'r');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 86400); // 1 Day Timeout
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file_path));
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$rsp=curl_exec ($ch);
if (curl_errno($ch))
print_r( curl_error($ch));
curl_close ($ch);
但它没有显示任何错误。如果我正在打印 res,它会给出“格式错误”。有什么建议吗?