1 additional step to automatically write on your Facebook Page wall AS the page itself using the Graph API
Today I’ve got a little addition to yesterdays post in which I explained 5 steps to post a status message to Facebook without a logged in user. Following that post you are able to post on your Facebook Page wall as yourself.
But you might want to post as the Page itself.
It’s easy to do. Simply follow the steps 1 to 4. Now before attempting to post lets explain your current status.
You’ve got a permanent access token granted by yourself to your application which you can use to do whatever you want to and whatever you granted enough permissions for.
When you want to act as your Page though you have to swap this access token for one that is specific to your Page.
4b. Swap your personal access token for a Page access token
Here’s a simple function that does the trick.
When you authorized your app with the manage_pages permission you ensured that your app has access to all your pages and application pages which are returned by /me/accounts in a sort of access token collection.
Pick the one with the required page id and grab the access token from it.
Now return to step 5 and simply replace the old access token with the new one you just swapped.