public function GoogleAnalyticsCounterFeed::query in Google Analytics Counter 7.3
Public query method for all Core Reporting API features.
6 calls to GoogleAnalyticsCounterFeed::query()
- GoogleAnalyticsCounterFeed::queryAccounts in ./
google_analytics_counter_oauth2.lib.inc - Query Management API - Accounts.
- GoogleAnalyticsCounterFeed::queryGoals in ./
google_analytics_counter_oauth2.lib.inc - Query Management API - Goals.
- GoogleAnalyticsCounterFeed::queryProfiles in ./
google_analytics_counter_oauth2.lib.inc - Query Management API - Profiles.
- GoogleAnalyticsCounterFeed::queryReportFeed in ./
google_analytics_counter_oauth2.lib.inc - Query and sanitize report data.
- GoogleAnalyticsCounterFeed::querySegments in ./
google_analytics_counter_oauth2.lib.inc - Query Management API - Segments.
File
- ./
google_analytics_counter_oauth2.lib.inc, line 255 - Provides the Google Analytics Counter Feed object type and associated methods. Most of the Google Analytics authentication process is taken over from http://drupal.org/project/google_analytics_reports because all we need here is its Google Analytics…
Class
- GoogleAnalyticsCounterFeed
- GoogleAnalyticsCounterFeed class to authorize access to and request data from the Google Analytics Core Reporting API.
Code
public function query($url, $params = array(), $method = 'GET', $headers, $cache_options = array()) {
$params_defaults = array(
'start-index' => 1,
'max-results' => 1000,
);
$params += $params_defaults;
// Provide cache defaults if a developer did not override them.
$cache_defaults = array(
'cid' => NULL,
'expire' => google_analytics_counter_cache_time(),
'refresh' => FALSE,
);
$cache_options += $cache_defaults;
// Provide a query MD5 for the cid if the developer did not provide one.
if (empty($cache_options['cid'])) {
$cache_options['cid'] = 'GoogleAnalyticsCounterFeed:' . md5(serialize(array_merge($params, array(
$url,
$method,
))));
}
$cache = cache_get($cache_options['cid']);
if (!$cache_options['refresh'] && isset($cache) && !empty($cache->data)) {
$this->response = $cache->data;
$this->results = json_decode($this->response->data);
$this->fromCache = TRUE;
}
else {
$this
->request($url, $params, $headers);
}
if (empty($this->error)) {
cache_set($cache_options['cid'], $this->response, 'cache', $cache_options['expire']);
}
return empty($this->error);
}