You are here

public function GAFeed::getRequestToken in Google Analytics Reports 7

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

OAuth step #1: Fetch request token.

File

./GAFeed.lib.inc, line 93
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-reports/oauth', array(
      'absolute' => TRUE,
    )),
    'xoauth_displayname' => t('Google Analytics Reports 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;
}