我在尝试上传视频广告时遇到以下错误:
<div class="row">
<div id="media-contents" class="col-lg-12">
<% if @media_contents.empty? %>
<h2 id="no-media">Dosya Bulunamadı</h2>
<% else %>
<% @media_contents.each do |media| %>
<div class="col-lg-4 tel_show">
<div class="thumbnail">
<%= image_tag media.file_name.url %>
<div class="caption">
<p>
<%= check_box_tag "media_contents[]", media.id %>
</p>
</div>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
。
您的视频上传在完成之前已超时。这可能是因为网络连接速度较慢或者您尝试上传的视频太大。请再试一次
连接正常,视频不是太大..块(1MB)。
知道问题可能是什么?
我的代码:
Error Code : 1363030
修改
要创建块,我使用了这个命令
$transfer = array();
$transfer["access_token"] = "G4535PZXXX";
$transfer["upload_phase"] = "transfer";
$transfer["upload_session_id"] = $upload_session_id";
$transfer["start_offset"] = $start_offset";
$transfer["video_file_chunk"] = @$filepath;
print_r($transfer);
//traverse array and prepare data for posting (key1=value1)
foreach ($transfer as $key => $value) {
$post_items[] = $key . '=' . $value;
}
//create the final string to be posted using implode()
$post_string = implode('&', $post_items);
//create cURL connection
$curl_connection = curl_init('https://graph-video.facebook.com/v2.3/act_XXX/advideos');
//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
//perform our request
$transfer_response = curl_exec($curl_connection);
//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . '-' . curl_error($curl_connection);
//close the connection
curl_close($curl_connection);
答案 0 :(得分:2)
从PHP 5.5.0开始,不推荐使用@前缀,可以使用CURLFile发送文件。 见CURLOPT_POSTFIELDS @ http://php.net/manual/en/function.curl-setopt.php
$video_file_chunk = new CURLFile($filepath,'video/mp4');
$transfer = array();
$transfer["access_token"] = "G4535PZXXX";
$transfer["upload_phase"] = "transfer";
$transfer["upload_session_id"] = $upload_session_id";
$transfer["start_offset"] = $start_offset";
$transfer["video_file_chunk"] = $video_file_chunk;
//create cURL connection
$curl_connection = curl_init('https://graph-video.facebook.com/v2.3/act_XXX/advideos');
//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $transfer);
//perform our request
$transfer_response = curl_exec($curl_connection);
//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . '-' . curl_error($curl_connection);
//close the connection
curl_close($curl_connection);
&#13;
答案 1 :(得分:1)
对于之后发现此情况的人,如果您未指定附加文件的内容类型和文件名(即,如果您将其作为内联字段值传递,而不是作为附加文件),则会发生此Facebook错误。
我经常不使用PHP,因此无法提供正确的curl命令,但上面的代码似乎有错误,因为它使用@
运算符(“抑制错误”)而不是将@
- 前缀文件名传递给curl。相应的行应为:
$transfer["video_file_chunk"] = '@' . $filepath;
不确定这是否足以解决PHP中的整体问题。