views:

405

answers:

2

Hello,

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

+1  A: 

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.

jostster
Yes, I have tried this before; I am getting no response from the api-video server.
Kevin Sedgley
@Kevin try using the new url i just posted in my answer.
jostster
@Kevin and @mattbasta Try the edit I just posted.
jostster
A: 

How to get $session_key in the above code ?

Venkatesh
you get it from the cookie.
jostster