function fb_connect_user in Drupal for Facebook 6.2
Same name and namespace in other branches
- 5.2 fb_connect.module \fb_connect_user()
Implementation of hook_user
On logout, redirect the user so facebook can expire their session. Should be a facebook API to do this, but there's none I know of.
File
- ./
fb_connect.module, line 291 - Support for Facebook Connect features
Code
function fb_connect_user($op, &$edit, &$account, $category = NULL) {
if ($op == 'logout') {
// Affect connect pages, but not canvas pages.
if (fb_is_fbml_canvas() || fb_is_iframe_canvas()) {
return;
}
$apps = fb_connect_enabled_apps();
foreach ($apps as $fb_app) {
try {
$fb = fb_api_init($fb_app, FB_FBU_CURRENT);
if ($fb && $fb->api_client->session_key) {
// Log out of facebook
$session_key = $fb->api_client->session_key;
// Figure out where to send the user.
if ($_REQUEST['destination']) {
$next = url($_REQUEST['destination'], array(
'absolute' => TRUE,
));
// It pains me to muck with $_REQUEST['destination'], but facebook's weak-ass API leaves us little choice.
unset($_REQUEST['destination']);
}
else {
$next = url('<front>', array(
'absolute' => TRUE,
));
}
// http://forum.developers.facebook.com/viewtopic.php?id=21879
// Use next parameter to expire session.
drupal_goto("http://www.facebook.com/logout.php?app_key={$fb_app->apikey}&session_key={$session_key}&next=" . $next);
}
} catch (Exception $e) {
fb_log_exception($e, t('Failed to log out of fbConnect session'));
}
}
}
}