将视频上传到旧的 Facebook REST API

发布于 2024-09-10 05:35:49 字数 875 浏览 3 评论 0原文

我在上传视频时遇到很多问题。

如果我尝试使用 https://api-video.facebook.com,如果我使用 http://api-video.facebook.com,我会收到 cURL 主机未找到错误

如果我尝试使用 https://api.facebook.com/restserver.php?method=video.upload 我收到 101 错误代码 -

<error_msg>Invalid API key</error_msg>

但 API 密钥有效对于其他一切,状态、评论、喜欢、用户的 FQL?

这是我要发送的内容:

access_token=XXXX
api_key=XXXX
call_id=1279204007.6003
description=Description+of+this%3F
format=JSON
title=Title%2C+a+title
v=2.0
sig=XXX

我在 FB 开发者论坛上读到的帖子 将会话密钥分割为 |给你一个正确的会话密钥?这和access_token一样吗?我尝试过将其分开,但没有成功。

任何想法,甚至 PHP 中的工作代码(!)都将受到欢迎!谢谢

I'm having lots of issues with uploading videos.

If I try to use https://api-video.facebook.com I am getting a cURL host not found error, if I use http://api-video.facebook.com I get a message to use https://api-video.facebook.com

If I try to use https://api.facebook.com/restserver.php?method=video.upload I get a 101 error code -

<error_msg>Invalid API key</error_msg>

but the API key works for everything else, statuses, comments, likes, fql for the user?

Heres what I am sending:

access_token=XXXX
api_key=XXXX
call_id=1279204007.6003
description=Description+of+this%3F
format=JSON
title=Title%2C+a+title
v=2.0
sig=XXX

I read in the post on the FB developers forum that splitting the session key by | gives you a correct session key? Is this the same as access_token? I have tried splitting this up with no luck.

Any ideas, or even working code in PHP (!) would be most welcome! Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

坏尐絯℡ 2024-09-17 05:35:50

尝试将代码与FB SDK一起使用

require_once 'facebook.php';

$appapikey = 'xxx';
$appsecret = 'xxx';
$facebook = new Facebook($appapikey, $appsecret);

$session_key = 'xxx'; //this is the infinite session_key returned when asking for the offline_access extended permission

    $args = array(
          'method' => 'facebook.video.upload',
          'v' => '1.0',
          'api_key' => $appapikey,
          'call_id' => microtime(true),
          'format' => 'JSON',
          'session_key' => $session_key,
          'title'       => 'My video title',
          'description' => 'My video description'
    );

      ksort($args);
      $sig = '';
      foreach($args as $k => $v) {
        $sig .= $k . '=' . $v;
      }
      $sig .= $appsecret;
      $args['sig'] = md5($sig);

    $args["short.wmv"] = '@E:\path\to\short.wmv';

    $ch = curl_init();
    $url = 'http://api-video.facebook.com/restserver.php?method=facebook.video.upload';
    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);

    print_r($data); //returned xml here

我还发现了错误报告 指出视频上传一直正常工作,但偶尔无法正常工作。可能是你的代码很好,而 facebook 的 API 却搞砸了。

编辑:

尝试以下,它似乎对少数人有效。

Try using this code with the FB SDK

require_once 'facebook.php';

$appapikey = 'xxx';
$appsecret = 'xxx';
$facebook = new Facebook($appapikey, $appsecret);

$session_key = 'xxx'; //this is the infinite session_key returned when asking for the offline_access extended permission

    $args = array(
          'method' => 'facebook.video.upload',
          'v' => '1.0',
          'api_key' => $appapikey,
          'call_id' => microtime(true),
          'format' => 'JSON',
          'session_key' => $session_key,
          'title'       => 'My video title',
          'description' => 'My video description'
    );

      ksort($args);
      $sig = '';
      foreach($args as $k => $v) {
        $sig .= $k . '=' . $v;
      }
      $sig .= $appsecret;
      $args['sig'] = md5($sig);

    $args["short.wmv"] = '@E:\path\to\short.wmv';

    $ch = curl_init();
    $url = 'http://api-video.facebook.com/restserver.php?method=facebook.video.upload';
    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);

    print_r($data); //returned xml here

I also found a bug report submitted today stating that video uploads have been working and not working sporatically. It could be your code is just fine and facebook's APIs are messing up.

EDIT:

Try the following, it seems to have worked for a few people.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文