Created
February 4, 2013 12:23
-
-
Save mingomax/4706458 to your computer and use it in GitHub Desktop.
Using PHP SDK from Facebook to upload a photo.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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