Upload Video to Facebook using PHP SDK

507 views Asked by At

I want to write a PHP script, that uploads a video from the server to the user's Facebook wall.

Here is the script:

try{
  $response = (new FacebookRequest(
    $session,
    'POST',
    '/me/videos',
    array (
      'source' => "@".realpath('123.mp4')
    )
  ))->execute()->getGraphObject();
} catch (Exception $e){
  echo $e->getMessage();
}

But I get an exception:

(#353) You must select a video file to upload

Can anybody tell me what I'm doing wrong here?
I'm using PHP 5.4.36-0+deb7u3 on my server.

1

There are 1 answers

0
Roemer On

The problem is that realpath just fills in the full path of the video file on your server. You need to send the video data in the request.

Would it be able to update to 5.5.x? This series was introduced on 2013-07-18, almost two years ago(!). Alternatively, I believe you can plugin curl support to your php configuration.