views:

5299

answers:

5

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.

A: 

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
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
what methods would that be?
ax
The User.getSession method. I am trying to retrieve their stream of status updates.
Mattew
see EDIT: for how this seems to work
ax
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
+2  A: 

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;
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
A: 

Hey Mattew: did you find an final answer to your question: I have the same question just basically step-by-step and valid for the today's fb api, which they seem to change on regulatory basis.

See SO question Facebook offline access step-by-step.

rgds ben

A: 

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....

+1  A: 

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