logout of facebook, while logged in to fb connect website
nighthawk117 - October 30, 2009 - 16:33
| Project: | Drupal for Facebook |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I've noticed that if a user is logged out of facebook (say they login from another computer or browser) while they are connected to the site then I get an error as follows:
Facebook API exception Session key invalid or no longer valid.
#0 C:\<path_to_drupal>\drupal\sites\all\modules\fb\facebook-platform\php\facebookapi_php5_restlib.php(1056): FacebookRestClient->call_method('facebook.friend...', Array)
#1 C:\<path_to_drupal>\drupal\sites\all\modules\fb\fb.module(460): FacebookRestClient->friends_get()
#2 C:\<path_to_drupal>\drupal\sites\all\modules\fb\fb_views\fb_views_handler_filter_friends.inc(21): fb_get_friends('423', Object(stdClass))
#3 C:\<path_to_drupal>\drupal\sites\all\modules\views\includes\view.inc(660): fb_views_handler_filter_friends->query()
#4 C:\<path_to_drupal>\drupal\sites\all\modules\views\includes\view.inc(587): view->_build('filter')
...I realize this bug is probably an uncommon corner case, but I think it can be fixed by updating line 449 in fb.modules to read:
try{
$fb->api_client->users_getLoggedInUser();
}
catch(Exception $e){
//TODO: this should forward to login page
return;
}BUT I don't know how to forward the user to the fb_connect initialization page! Is there a function I can call that will get this process going? Thanks!

#1
Agreed there should be no error.
About forwarding the user, I'm not sure you want to forward them anywhere. Just treat them as a not logged in user. the code in fb_connect.js should reload the page, thus showing they are not logged in.
#2
Not sure I'm following you on this, are you suggesting that fb_connect.js poll Facebook and reload the page if the session disappears? I'm ok with just treating them as a logged out user, but I'm not clear on how to accomplish this. It seems like I may need to wrap every call the facebook api's with a try catch block... but even if that's the fix, what exactly would go in the catch block?
#3
Actually, I think I understand what you're saying... Typically the js will reload the page immediately after page load, if the fb session has disappeared. So the appropriate action here is to simply return empty content, display it, and allow the js to reload the page to reflect that the user is no longer authenticated. Correct?
#4
Ignoring facebook connect for a moment... Say you're logged into a drupal site. You leave that page in your browser for a long time, during which the drupal cookies expire. Next time you click a link or refresh the page, you'll find yourself logged out. (But until you click, it appears like your logged in). This is common behavior on most websites, not drupal-specific.
Now, with facebook connect... Say you're logged in to faceobok and an DFF-powered site. You log out of facebook. In your other window, the DFF site does not update automatically. When you click a link or refresh a page, then you discover you are not logged in. Again, not drupal-specific, I think most if not all facebook connect sites will behave this way.
I don't think DFF needs to handle this case any differently. Do you?
#5
Hm ok, so I'll just update access args for any page making calls to fb's api. For some reason I wanted more than that, but it does seem to work just fine...