You are here

function fb_user_get_proxied_email in Drupal for Facebook 6.2

Same name and namespace in other branches
  1. 6.3 fb_user.module \fb_user_get_proxied_email()
  2. 7.3 fb_user.module \fb_user_get_proxied_email()

Learn the user's proxied email address. http://wiki.developers.facebook.com/index.php/Proxied_Email

2 calls to fb_user_get_proxied_email()
fb_user_fb in ./fb_user.module
Implementation of hook_fb.
fb_user_user in ./fb_user.module
Implementation of hook_user.

File

./fb_user.module, line 430
This module manages relations between local Drupal user accounts and their accounts on facebook.com.

Code

function fb_user_get_proxied_email($fbu, $fb_app) {

  // Try to learn from local database
  $result = db_query("SELECT * FROM {fb_user_app} WHERE apikey='%s' AND fbu=%d", $fb_app->apikey, $fbu);
  if ($data = db_fetch_object($result)) {
    $mail = $data->proxied_email;
  }
  if (!$mail) {

    // Ask facebook for info.
    $fb = fb_api_init($fb_app);
    $info = fb_users_getInfo(array(
      $fbu,
    ), $fb);
    $data = $info[0];
    $mail = $data['proxied_email'];
    if ($mail && variable_get(FB_USER_VAR_STATS, TRUE)) {

      // Store locally.
      $result = db_query("UPDATE {fb_user_app} SET proxied_email='%s' WHERE apikey='%s' AND fbu=%d", $mail, $fb_app->apikey, $fbu);
    }
  }
  return $mail;
}