I'm trying to add a feature to my app that will post a status to a admin user's page timeline with the same detail as if they posted on Facebook.com. The main feature I am focusing on is the link sharing and thumbnail images, like when you paste a link into your status and it auto-detects a thumbnail image, gives you a nice link, description, etc. I have tireless read through other forums and the Graph API documents, and I keep running into problems with the post showing as the admin user, rather than the page. Here is my code:
$facebook = new Facebook(array(
'appId' => $appID,
'secret' => $appSecret,
));
$loginUrl = $facebook->getLoginUrl(array(
"scope" => 'publish_stream, read_insights, manage_pages, photo_upload, video_upload, create_note, manage_notifications'
));
$access_token = $facebook->getAccessToken();
$fbpost = array();
$fbpost['access_token'] = $access_token;
$fbpost['message'] = $message;
$fbpost['link'] = $link;
$fbpost['description'] = $description;
$fbpost['caption'] = $caption;
$fbpost['picture'] = $fbimg;
$status = $facebook->api('/'.$pageID.'/feed', 'POST', $fbpost);
var_dump($status);
When I only post the $fbpost['message'] it correctly posts the status as the page, but when I add ANYTHING else it shows the post as the authenticated admin user instead of the page. Very frustrating. Any ideas?
Then get a page access token, not a user access token for the admin user …
Thanks to CBroe for providing a link to the Facebook docs on the page/app access token. After checking that out, I came up with this PHP (since there is no good documentation in the PHP SDK for getting a page access token):