You are here

function fb_user_get_proxied_email in Drupal for Facebook 7.3

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

Learn the user's proxied email address. If fb_user_app.module is enabled, it will defer to that module, which queries a local database. If not, ask facebook for the data.

@TODO: Facebook may no longer provide proxied_email. Does this work?

1 call to fb_user_get_proxied_email()
fb_user_user_load in ./fb_user.module
Implements hook_user_load.

File

./fb_user.module, line 1250
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) {
  $mail = "";
  if (function_exists("fb_user_app_get_proxied_email")) {

    // Function at fb_user_app module queries fb_use_app table first
    $mail = fb_user_app_get_proxied_email($fbu, $fb_app);
  }
  if (!$mail) {

    // Ask facebook for info.
    $fb = fb_api_init($fb_app);
    $info = fb_users_getInfo(array(
      $fbu,
    ), $fb);

    // TODO deprecated
    $data = $info[0];
    if (isset($data['email'])) {
      $mail = $data['email'];
    }
    elseif (isset($data['proxied_email'])) {
      $mail = $data['proxied_email'];
    }
  }
  return $mail;
}