Facebook api video.upload 需要 HTTPS 连接
当我尝试使用 CURL 将视频上传到 Facebook 时,我注意到 Facebook API 返回了一条非常有趣的错误消息,如下所示:
此方法需要 HTTPS 连接
基于 facebook api 文档:developers.facebook.com/docs/ref … deo.upload 它写道:
视频上传到 Facebook 发生在一组特定的服务器上。当您调用 video.upload 时,您需要考虑这一事实。您必须对 http://api-video.facebook.com 进行 video.upload 调用,并且不是 api.facebook.com。如果您调用 api.facebook.com,则会返回错误。
奇怪的是,我尝试将协议从 HTTP 更改为 HTTPS,然后收到了不同的错误消息。这次。它告诉我主机不存在。
有人可以帮忙吗?
这是我的 php 代码
代码:
$args = array( '方法' => '视频.上传', '标题' => '我的视频', '描述' => '通过 API 测试我的视频上传', 'access_token'=>; $facebook->getAccessToken(), 'api_key'=>$fbconfig['api'] );
$args["kdVBRO1IU.flv"] = '@'.SITE_PATH.'temp/kdVBRO1IU.flv';
//echo $args["AtXAI8Pdt.flv"];
//$statusUpdate = $facebook->api($args);
$ch = curl_init();
$url = 'http://api-video.facebook.com/restserver.php';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$data = curl_exec($ch);
I noticed a very funny error message Facebook API returns when I tried to use CURL to upload video to Facebook as below:
This method requires an HTTPS connection
Based on facebook api doc: developers.facebook.com/docs/ref … deo.upload
it wrote that:
Video uploads to Facebook happen on a specific set of servers. When you call video.upload, you need to account for this fact. You must make the video.upload call to http://api-video.facebook.com, and not api.facebook.com. If you call api.facebook.com, an error gets returned.
Curiously, I tried to change the protocol from HTTP to HTTPS then I got a different error message. This time. it is telling me that the host does not exist.
Could anyone please help?
Here is my php code
Code:
$args = array(
'method' => 'video.upload',
'title' => 'my video',
'description' => 'Test my video upload via API',
'access_token'=> $facebook->getAccessToken(),
'api_key'=>$fbconfig['api']
);
$args["kdVBRO1IU.flv"] = '@'.SITE_PATH.'temp/kdVBRO1IU.flv';
//echo $args["AtXAI8Pdt.flv"];
//$statusUpdate = $facebook->api($args);
$ch = curl_init();
$url = 'http://api-video.facebook.com/restserver.php';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$data = curl_exec($ch);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢您的输入 BeRecursive,我花了一段时间才让它工作
我使用的 URl 是
http://api-video.facebook.com/facebook.upload .video
很奇怪,因为我找不到任何有关此 URL 的文档,但是,根据 Facebook 开发者论坛上的一篇帖子,我得到了它。
Thanks for your input BeRecursive, It took me awhile to get it working
The URl I used is
http://api-video.facebook.com/facebook.upload.video
Quite strange as I could not find a single document mention about this URL, however, following one of the post on facebook developer forum then I got it.