Archive for the ‘Facebook API’ Category
How to Post to a Facebook Page using the API

I spent many hours figuring out how to do this one simple thing. Post to a facebook page using the API. So first we need a little bit of a process map so you better understand what needs to be done. For most of the code I will present you will need the application ID and in some cases the secret key in order to authenticate with the API. These are shown in the code below as $app_id and $app_secret.
1. You have to get the user access code. This is not to be confused with the user access token which is what you ultimately need to find the pages and page tokens needed to post to a page. The user access code has a strange way of getting the code. You have to grab it using a URL and in that URL you need to specify a URL to capture the code. The user access code will be passed in a GET on the redirect URL you provide.
https://www.facebook.com/dialog/oauth?client_id=".$app_id."&redirect_uri=".$return_auth_url."&scope=manage_pages,publish_stream&response_type=code";
Read the rest of this entry »