10

I am using Facebooker with Rails to connect my application to Facebook. I can direct the user through the authorization process and through the process of granting offline access to my application.

How do I actually go about accessing the information offline? Is there a way to request a session_key that does not expire that I can use at a later point, so long as the user has not revoked the permissions for my application on Facebook?

Any help greatly appreciated. Advice need not be rails specific.

Ólafur Waage
  • 68,817
  • 22
  • 142
  • 198
Mattew
  • 537
  • 2
  • 7
  • 13

4 Answers4

2

Once you ask for, and are granted, offline access the session key you get in the HTTP POST parameters from Facebook (fb_sig_session_key) will have no expiry.

You can check you have such a key by checking the fb_sig_expires parameter, if this is "0" then the session key has no expiry.

If you have an auth_token then you can call getSession to get the session key and check the expires field:

var auth = _auth.getSession(AuthToken);
string sessionKey = auth.session_key;
long uid = auth.uid;
bool expires = auth.expires > 0;
  • 2
    Hi Mark - thanks for the info. Do you know if the session key changes after you are granted offline access? In Facebooker, the session key I get back seems to be the same as the one I started with, and it has an expiration. Matt – Mattew Mar 20 '09 at 18:41
1

I just made a tutorial on my blog with a step by step explanation on how to access offline user's data. It assumes you're working with RoR and the Facebooker plugin.

Pierre Olivier Martel
  • 3,144
  • 4
  • 26
  • 30
0

Once you get offline access permission from a user, the trick is to call with a filter_key parameter of 'network'.

In PHP, it is:

$feed = $facebook->api_client->stream_get($uid, '', '', '', 20, 'network', '');

Try it, it works....

sth
  • 222,467
  • 53
  • 283
  • 367
0

EDIT: apparently, granting "offline_access" still gives you (and will continue doing so) an infinite session key. just save this special key and use it in your call to Status.get etc. see here for a (PHP) code example.

http://wiki.developers.facebook.com/index.php/New_Design_User_Login :

many API calls no longer require session keys

so if your app is granted offline_access, you can use API calls listed here without a session_key.

And we're changing more methods so you won't need a session key to do something when the user is offline, like send a notification.

ax.
  • 58,560
  • 8
  • 81
  • 72
  • Thanks for the information on functions not requiring a session key. Unfortunately the methods I need require a session_key that does not expire. – Mattew Mar 06 '09 at 23:35
  • The User.getSession method. I am trying to retrieve their stream of status updates. – Mattew Mar 08 '09 at 21:58
  • Thanks for the edit. I need to review the facebooker code, as the session key I am getting after offline access is granted still has an expiration date. I suspect that facebook issues a new session key once offline access has been granted and facebooker is not updating it. – Mattew Mar 17 '09 at 13:58