Last updated March 19, 2013. Created by Dave Cohen on November 11, 2010.
Log in to edit this page.
fb_facebook_user()
fb.module provides a method, fb_facebook_user(), which returns the user's ID on facebook. It will return a positive integer if a) the user is logged into facebook and b) has authorized your application. In other words, if they are connected this function returns their ID.
<?php
if ($fbu = fb_facebook_user()) {
// The user is connected to facebook and $fbu is their ID.
}
else {
// The user is ether not logged into facebook or has not authorized the application.
}
?>fb_get_fbu()
fb.module also provides fb_get_fbu(), which will tell you whether a local drupal account is connected to a facebook account. This will return a facebook user id regardless of whether the user is currently logged into drupal of facebook.
<?php
if ($fbu = fb_get_fbu(42)) {
// The local user with uid == 42 is mapped to a facebook ID ($fbu).
}
else {
// The local user with uid == 42 is not connected to facebook.
}
?>