Hi Dave,
My infinite session expired. So I did a little debugging and I think I have solved your problem (assuming that there is a problem and I didn't make some other mistake).
Firstly though - in the app setup your give a link to get session key and mention that if prompted tick the box to prevent session from expiring.... I can't seem to do this. Is it an old feature that doesn't exist in new facebook? If I am already logged into FB it goes straight to session details. If I log out it just won't work (says the url doesn't exist).
I notice in fb_infinite that you have a field for the one time code but you say you couldn't get it to work.
I turned on the api debug ($conf['fb_debug']= TRUE; in settings.php) and noticed that it didn't seem to be sending the session details.
Then I realized that it was because I was administering from a non fb user (my admin user). I'm not sure if administering from fb user is an option, but I don't think so, because I gave it a try and editing the app seem to have some issues.
So that lead me to making some changes to fb_infinite_nodeapi
1. Make it a two step process. First save the session key to the app. Then go back and save the one time code. Thus you can use FB_FBU_INFINITE_SESSION rather then the non existent "current" session.
2. $fb_app doesn't seem to exist and $node->fb_app doesn't seem to have all the data. So get a new $fb_app using $node->nid.
In short I changed this:
$fb = fb_api_init($fb_app, FB_FBU_CURRENT); // Does not set user.
to this:
$fb_app = fb_get_app(array('nid' => $node->nid));
$fb = fb_api_init($fb_app, FB_FBU_INFINITE_SESSION); // Does not set user.
The result was that the session key did not change, but the expiry was 0. So I am hoping this key won't expire now.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | fb_infinite.diff | 644 bytes | Dave Cohen |
Comments
Comment #1
NigelC commentedOh and I un-commented the form... look for the comment "I can't get this to work".
Also, its not perfect. The one time code needs to be removed from the app otherwise it doesn't seem to work next time (makes sense - its a "one" time value). However if I try to request another one time code it doesn't work again.... So it needs a bit more work yet.
Comment #2
NigelC commentedah. I take it back. I think the problem was that I was printing debug messages and then hitting the back button (so the form remained filled out from previous post).
I have gone back and tried again with just the changes mentioned (and without debug) and it all works. The one time value disappears and it can be done multiple times and still works. Might be nice to fix up the message to show expiry = 0 in a more user friendly way, but otherwise its good.
Comment #3
Dave Cohen commentedNigel,
Thanks for catching the problem and the detail report. As you point out the bit about checking the box on the facebook form was from the older facebook. So that is obsolete.
In fact my understanding is that the entire notion of an infinite session is obsolete. Now simply having the apikey and secret should be enough. So I've been meaning to get rid of this module entirely. I just haven't taken the time to confirm that's the right thing to do.
So, what exactly are you doing with the infinite session and have you tried without it?
Also based on your report, I think changing just one line will work, as shown in this patch. Although I haven't really tested.
Comment #4
Dave Cohen commentedNigel,
As I mentioned, I believe infinite sessions are now deprecated and make no sense in the new Facebook API. I have not removed them entirely, but plan to once I'm sure they're not necessary.
I've introduced FB_FBU_NO_SESSION. Calling fb_api_init with that should allow you to do all the things infinite sessions allowed you to do. I'm going to eventually replace all the places where infinite sessions are used in the modules.
I've also checked in the patch above as I think it will solve your problem. Feel free to open this bug again if I'm mistaken.