k-shimi musicTech-life

Blog by Shimon Koifman

Posts Tagged ‘infinite session’

Facebook and external services

Posted by shimikoif on April 13, 2008

How to create mobile service as Facebook application…

Creating an application that will run on top of Facebook platform is an easy journey…
You should have knowledge in web applications life-cycle as well as some programing capabilities in Java,PHP or Python (JavaScript/AJAX is also an option).

The difficult part is when you want:

  • The application to perform tasks that are on-behalf of the users
  • To enable user activity on disconnected mode (from mobile device – without a browser)

Luckily… Facebook platform DO provide facilities to overcome the problems mentioned above.

They (Facebook) call them “infinite session keys”.

Here is what you need to do (In Java):

  • Generate a one time code by accessing the following URL in a browser: http://www.facebook.com/code_gen.php?v=1.0&api_key=YOUR_API_KEY

  • Use the generated code instead of the auth_token that is normally passed to the auth.getSession.
  • The session returned from this call is known as your “Infinite Session Key” and can be used to setup in any external program. e.g.

    FacebookRestClient facebookRestClient = new FacebookRestClient(apiKey, secretKey);
    facebookRestClient.auth_getSession(oneTimeCode); // get infinite session using the one time code

  • That’s it! Your external program should now be able to access the Facebook API just as if it was running inside Facebook

Posted in mashups, web 2.0 | Tagged: , , , | 5 Comments »