Skip to content

Instantly share code, notes, and snippets.

Created October 7, 2013 17:52
Show Gist options
  • Save anonymous/6872121 to your computer and use it in GitHub Desktop.
Save anonymous/6872121 to your computer and use it in GitHub Desktop.
Modified version of 'https://github.com/eosgood/fbphpsdk/blob/master/async/photo.php' to support video uploads. Tested with 177 MB MKV video.
<?php
// Provides access to app specific values such as your app id and app secret.
// Defined in 'AppInfo.php'
require_once('../utils/AppInfo.php');
require_once('../facebook-php-sdk/src/facebook.php');
$facebook = new Facebook(array(
'appId' => AppInfo::appID(),
'secret' => AppInfo::appSecret(),
));
$facebook->setFileUploadSupport(true);
if (isset($_POST['graph'])) {
$user = $facebook->getUser();
$data = array();
$img = '../vid/example.mkv';
$post_data = array(
'videoData' => '@' . $img,
'title' => 'Test Video Upload',
'description' => 'Video uploaded with the php sdk',
);
try {
$data = $facebook->api(
'/me/videos', 'POST',
$post_data
);
} catch(FacebookApiException $e) {
$data = array('error' => $e->getMessage());
}
echo json_encode($data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment