Skip to content

Instantly share code, notes, and snippets.

@mingomax
Created February 4, 2013 12:23
Show Gist options
  • Save mingomax/4706458 to your computer and use it in GitHub Desktop.
Save mingomax/4706458 to your computer and use it in GitHub Desktop.
Using PHP SDK from Facebook to upload a photo.
<?php
if(isset($_FILES["source"]["name"]))
{
try {
$facebook->setFileUploadSupport(true);
$response = $facebook->api(
'/me/photos/',
'post',
array(
'message' => $_POST['message'],
'source' => '@'.$_FILES["source"]["tmp_name"]
)
);
}
catch (FacebookApiException $e) {
error_log('Could not post image to Facebook.');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment