Facebook: Infinite Session Keys
Facebook infinite session keys provide a great way for developers to write external applications and allow them to interface with your Facebook applications.
This is particularly useful when you need to write a batch / cron job that requires access to the Facebook API.
I found the online documentation to be pretty cryptic, so I thought I would document the steps involved to set this up:
This is particularly useful when you need to write a batch / cron job that requires access to the Facebook API.
I found the online documentation to be pretty cryptic, so I thought I would document the steps involved to set this up:
- 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.
PHP:
$facebook = new Facebook($api_key, $secret);
$facebook->set_user($myuid, $infkey);
Java:
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.


0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home