Question: How to upload an image from my webserver to facebook via FB API?
I\'m writing an application that retrieves images from the user\'s photo album, makes some
The code in this question use the outdated REST APIs, that will soon be discontinued.
The correct way now is:
$fbk = new Facebook(/* conf */);
$fbk->setFileUploadSupport(true);
//If you are executing this in a script, and not in a web page with the user logged in:
$fbk->setAccessToken(/* access token from other sources */);
//To add to an album:
$fbk->api("/$albumId/photos", "POST",
array('source' => '@'. realpath($myPhoto), 'message' => "Nice photo"));
//To upload a photo directly (the album will be created automatically):
$fbk->api("/me/photos", "POST",
array('source' => '@'. realpath($myPhoto), 'message' => "Nice photo"));
Remember the $fbk->setFileUploadSupport(true);