Authorizing a Facebook Fan Page for Status Updates Authorizing a Facebook Fan Page for Status Updates php php

Authorizing a Facebook Fan Page for Status Updates


I solved the problem by consulting the Facebook desktop application documentation (even though this is a web application).

I first had to authorize offline access with this url (replacing 'MYAPIKEY'):http://www.facebook.com/login.php?api_key=MYAPIKEY&connect_display=popup&v=1.0&next=http://www.facebook.com/connect/login_success.html&cancel_url=http://www.facebook.com/connect/login_failure.html&fbconnect=true&return_session=true&session_key_only=true&req_perms=read_stream,publish_stream,offline_access

Then, I needed to grant 'publish_stream' permissions to the PAGE with this url (replacing 'MYAPIKEY' and 'THEPAGEID'):http://www.facebook.com/connect/prompt_permissions.php?api_key=MYAPIKEY&v=1.0&next=http://www.facebook.com/connect/login_success.html?xxRESULTTOKENxx&display=popup&ext_perm=publish_stream&enable_profile_selector=1&profile_selector_ids=THEPAGEID

I could then use the following code to publish to the Fan Page wall:

require_once 'facebook-platform/php/facebook.php';$facebook = new Facebook(MYAPIKEY, MYAPISECRET);try{    $facebook->api_client->stream_publish('INSERT_STATUS_HERE',null,null,null,'THEPAGEID');}catch(Exception $o ){    print_r($o);}


Based on the above, i tried out a couple of querystring parameters on the graph API authorize URL, and it appears this works:

https://graph.facebook.com/oauth/authorize?client_id=[APP_ID]&redirect_uri=[REDIRECT_URL]&scope=publish_stream&enable_profile_selector=1&profile_selector_ids=[PAGE_IDS]

EDIT: Never mind, the above displays all the UI correctly, but still get the "(#200) The user hasn't authorized the application to perform this action" error --- it's clear it doesn't work because the access token contains my USER id but not the page's ID.