Google Search

Thursday, July 21, 2011

UPLOAD PHOTO TO FAN PAGE AS THE FAN PAGE USING FACEBOOK GRAPH API



keep getting "OAuthException: (#324) Requires upload file thrown" when trying to upload the image. found my solution here: http://forum.developers.facebook.net/viewtopic.php?id=91281. You'll need call setFileUploadSupport(true) for this to work


1. Require 'manage_pages' permission to manage the fan page on behalf of the user
2. Get the page's access_token by querying /me/accounts

code below will upload to app's default album in fan page.


$fb->setFileUploadSupport(true);
$file= 'images/imageToPost.jpg';
$args = array(
'message' => 'The photo\'s description',
'source' => '@' . realpath($file),
'access_token'=>'the access token from step #2'
);

$fb->api( '/[FAN_PAGE_ID]/photos', 'POST', $args);

0 comments:

Followers

Labels

About Me

Shah Alam, Selangor, Malaysia

Recent Posts

  © Free Blogger Templates 'Photoblog II' by Ourblogtemplates.com 2008

Back to TOP