You are here

function _fb_user_get_authmap in Drupal for Facebook 5

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

Helper function to create an authname for the authmap table.

When a single Drupal instance hosts multiple Facebook apps, the apps can share the same mapping, or each have their own.

Return value

an array with both a 'module' and an authname. A data structure necessary for Drupal's authmap api.

3 calls to _fb_user_get_authmap()
fb_user_create_local_user in ./fb_user.module
Creates a local Drupal account for the specified facebook user id.
fb_user_sync_cb in ./fb_user.module
The sync callback is invoked first on a canvas page, in which case we require the user to add the application. Later the user will be redirected to this callback on the locale server, with an token that allows us to write the necessary row to the…
fb_user_user in ./fb_user.module
Implementation of hook_user.

File

./fb_user.module, line 809
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_authmap($fb_app, $fbu) {
  $fb_app_data = fb_app_get_data($fb_app);
  $fb_user_data = $fb_app_data['fb_user'];

  // our configuration
  $app_specific = $fb_user_data['unique_account'];

  // map fbu to uid, include apikey if user is app_specific
  if ($app_specific) {

    // would rather use the shorter app id (not apikey), but no way to query it
    $authname = "{$fbu}-{$fb_app->apikey}@facebook.com";
    $module = "fb_user-{$fb_app->nid}";
  }
  else {
    $authname = "{$fbu}@facebook.com";
    $module = "fb_user";
  }

  //return array('module' => $module, 'authname' => $authname);
  return array(
    $module,
    $authname,
  );
}