You are here

public function GAFeed::getRequestToken in Google Analytics Counter 7.2

OAuth step #1: Fetch request token.

File

./GAFeed.lib.inc, line 96
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 getRequestToken() {
  $this
    ->setHost($this->oAuthHost);
  $this
    ->setQueryPath('accounts/OAuthGetRequestToken');

  /* xoauth_displayname is displayed on the Google Authentication page */
  $params = array(
    'scope' => 'https://www.googleapis.com/auth/analytics.readonly',
    'oauth_callback' => url('google_analytics_counter/oauth', array(
      'absolute' => TRUE,
    )),
    'xoauth_displayname' => t('Google Analytics Counter Drupal module'),
  );
  $this
    ->query($this->queryPath, $params, 'GET', array(
    'refresh' => TRUE,
  ));
  parse_str($this->response->data, $token);
  $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
  return $token;
}