Take the 2-minute tour ×

When trying to post a photo to an album (as the page, a page access token was used which was obtained from "/page_id?fields=access_token") I get the ID of the newly created object. However, this ID simply returns "false" when trying to check it in the graph explorer. Also, the photo does not seem to appear in the selected album (or anywhere else for that matter).

The code is pretty straightforward:

$facebook->setFileUploadSupport (true);
$page_at = $facebook->api ('/'.option::get_value ('page_id').'?fields=access_token');
$page_at = $page_at['access_token'];
$args = array ();
$args['message'] = $this->text;
$args['access_token'] = $page_at;
$photo = $facebook->api ('/'. option::get_value ('album_id') . '/photos', 'post', $args);

option::get_value () simply returns the (correct, I triple checked) album ID. Also, the image is a .png and I get no error message whatsoever, everything Facebook returns is the ID:

array(1) { ["id"]=> string(15) "188538791279108" }

Is this a Facebook bug or am I missing something obvious?

share|improve this question
$args['image'] = '@' . realpath ($filename); this only returns canonicalized absolute pathname. To upload the image to facebook, you have to pass the fullpath with domain.. e.g.; http://somesite.com/images/myimage.png –  Ram G Aug 24 '12 at 19:00
Unfortunately it really is the complete physical path, when I changed it to a bogus path I already got a HTTP 500 from my script because it couldn't find the file. Are you sure I need to pass a URL for this to work? –  Simon Krämer Aug 24 '12 at 19:28
Yeah. You have to pass full imageurl as source. –  Ram G Aug 24 '12 at 22:44

1 Answer 1

up vote 1 down vote accepted

Instead of the 'image' parameter, try 'source'. Just tried it and it worked for me (posting to an album owned by a page):

$args['source'] = '@'.realpath($filename);

Also, ensure the uploaded file has a non-zero file size:

error_log('file size: '.$_FILES["file"]["size"]);

And double-check the access token has manage_pages,publish_stream permissions using the Debugger.

share|improve this answer
Thanks! For some reason I forgot the publish_stream permission.. –  Simon Krämer Aug 27 '12 at 9:08

Your Answer


