Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uploading video to old Facebook REST API

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

like image 573
Kevin Sedgley Avatar asked Jul 15 '10 16:07

Kevin Sedgley


1 Answers

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.

like image 84
Bot Avatar answered Oct 13 '22 13:10

Bot