Blog

Facebook Graph API - Project

| 0 comments | facebook

I have managed to crack the OAuth thing that Facebook has taken up to authenticate web apps calling their new Graph API. I found it quite simple actually.

Before you can make restricted requests, you need to be first issued with an auth_token. To get one you need to send a request to:

https://graph.facebook.com/oauth/authorize?client_id=YOUR_APP_ID&redirect_uri=YOUR_APP_URL&scope=LIST_OF_OBJECTS

LIST_OF_OBJECTS is where you comma delimit the list of things you will want to access (ie events,photos,email etc). The call returns a code which you then use along with your secret to retrieve the auth_token

http://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&redirect_uri=YOUR_APP_URL&client_secret=YOUR_APP_SECRET&code=THE_CODE

The auth_token is then returned along with an expiry countdown in seconds. This can then be added to any API calls for which you need permission.

I have used just one PHP script to do everything. It just checks if its receiving instructions by the user to make a call as a GET variable else goes along through the authentication procedure until an auth_token is set

Feel free to test it out over at dyl.anjon.es/musicwall


Comments

Be the first to comment!

Add a comment