Using Facebook’s Graph API, I’ve been successful at publishing to a user’s feed while the user is offline with only the publish_stream permission. I don’t need the offline_access permission. I explained how I did this here: Facebook Stream Publish while offline
I haven’t been as successful with publishing to a Page while the user is offine. Here’s my scenario:
User U is an admin of Page P. P authorizes and installs my app. U authorizes my app and grants me the following extended permissions:
- publish_stream
- manage_pages
Once the user is offline, if I try the same technique I use to publish to a user’s stream (without offline_access permission) to instead publish to a Page, I get a “The user hasn’t authorized the application to perform this action”. Here’s the technique:
1) fetch my app’s access_token
2) use my app’s access_token to publish to Page P’s feed:
POST https://graph.facebook.com/{page_id}/feed
If instead of {page_id} in step 2, I use {user_id}, then it publishes to the user’s feed without any problem. However, I’d like to publish to the Page’s feed. Is it possible to do this? Or do I need the offline_access permission from the user in order to do this?
Thanks,
Johnny
The problem is you need to use the access token for the page provided via the premissions gained…
Uh… Easier way to say it is this:
Your app requested premission to “manage_pages” – once you accept/grant premission then you have an access_token for the apps premission (offline would just make expires=0 here)
So now your app has premission to manage your pages, but it needs the token for the specific page…
So if you issue a
/me/accounts(or/UID/accounts) with the first token you will get a list of the pages the application has premission to access and their respective tokens…From there just grab the token of the page and then issue your command with that token
Using the facebook class (
facebook.phpand cert file)You should see a llist of page id’s and their access tokens…
Usuually i do a
foreach $userdata['data']and look for the page id, then i grab the token from that subarray…