You are here

function fb_remote_auth_url in Drupal for Facebook 7.4

1 call to fb_remote_auth_url()
fb_admin_token_generate_process in ./fb.admin.inc

File

./fb.module, line 1021

Code

function fb_remote_auth_url($options) {
  $url = NULL;
  if (empty($options['fba'])) {
    $options = fb_get_app();
  }

  // defaults
  $options += array(
    'remote_uri' => fb_auth_redirect_uri(current_path(), array(
      'query' => array(
        'client_id' => $options['fba'],
      ),
    )),
    'scope' => '',
  );
  if (!empty($options['namespace'])) {

    // Pass user to canvas URL.  Can't pass normal query params to a canvas URL.
    // urlencode twice to avoid slash problems in apache.
    // This URL will provide an explanation page, or parse a token.
    $url = 'https://apps.facebook.com/' . $options['namespace'] . '/fb_remote/auth/' . urlencode(urlencode('scope=' . $options['scope'])) . '/' . urlencode(urlencode('site_name=' . variable_get('site_name', url('<front>', array(
      'absolute' => TRUE,
    ))))) . '/' . urlencode(urlencode('remote_uri=' . $options['remote_uri']));

    // This URL will get the token for the above URL to parse.
    $url = url('https://www.facebook.com/dialog/oauth', array(
      'query' => array(
        'scope' => $options['scope'],
        'client_id' => $options['fba'],
        'redirect_uri' => $url,
      ),
    ));
  }
  return $url;
}