Simon Krämer
Simon Krämer

Reputation: 38

FB: Unable to post a photo to an album on a Facebook page

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['image'] = '@' . realpath ($filename);
$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?

Upvotes: 0

Views: 672

Answers (1)

Donn Lee
Donn Lee

Reputation: 3149

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.

Upvotes: 1

Related Questions