You are here

public function GAFeed::obtainAuthorization in Google Analytics Reports 7

Same name and namespace in other branches
  1. 6 GAFeed.lib.inc \GAFeed::obtainAuthorization()

OAuth step #2: Authorize request token.

File

./GAFeed.lib.inc, line 113
Provides the GAFeed object type and associated methods.

Class

GAFeed
GAFeed class to authorize access to and request data from the Google Analytics Data Export API.

Code

public function obtainAuthorization($token) {
  $this
    ->setHost($this->OAuthHost);
  $this
    ->setQueryPath('accounts/OAuthAuthorizeToken');

  /* hd is the best way of dealing with users with multiple domains verified with Google */
  $params = array(
    'oauth_token' => $token['oauth_token'],
    'hd' => variable_get('google_analytics_reports_hd', 'default'),
  );

  // Check for the overlay.
  if (module_exists('overlay') && overlay_get_mode() == 'child') {
    overlay_close_dialog($this->queryPath, array(
      'query' => $params,
      'external' => TRUE,
    ));
    overlay_deliver_empty_page();
  }
  else {
    drupal_goto($this->queryPath, array(
      'query' => $params,
    ));
  }
}