function fb_user_get_local_user in Drupal for Facebook 5.2
Same name and namespace in other branches
- 5 fb_user.module \fb_user_get_local_user()
- 6.3 fb_user.module \fb_user_get_local_user()
- 6.2 fb_user.module \fb_user_get_local_user()
- 7.3 fb_user.module \fb_user_get_local_user()
Given an app and facebook user id, return the corresponding local user.
1 call to fb_user_get_local_user()
- fb_actions_cron_per_user in ./
fb_actions.module - Trigger an action several times, emulating a different user each time. Useful for cron jobs in which we update each users profile box, for example.
File
- ./
fb_user.module, line 763 - This module allows Drupal user records to be associated with Facebook user ids. It can create local user accounts when Facebook users visit an application's canvas pages.
Code
function fb_user_get_local_user($fbu, $fb_app) {
// TODO: this function should probably use user_external_load, rather than query the database directly. See deprecated fb_user_load for example.
// TODO: this query probably needs to search for one authname or the other, not both.
// Alternately, use the fb_user_app table rather than authmap to look up this information.
$result = db_query("SELECT am.* FROM authmap am WHERE am.authname='%s' OR am.authname='%s' ORDER BY am.authname", "{$fbu}-{$fb_app->apikey}@facebook.com", "{$fbu}@facebook.com");
if ($data = db_fetch_object($result)) {
$account = user_load(array(
'uid' => $data->uid,
));
return $account;
}
}