protected function GoogleAnalyticsReportsApiFeed::request in Google Analytics Reports 7.3
Execute a query.
1 call to GoogleAnalyticsReportsApiFeed::request()
- GoogleAnalyticsReportsApiFeed::query in google_analytics_reports_api/
google_analytics_reports_api.lib.inc - Public query method for all Core Reporting API features.
File
- google_analytics_reports_api/
google_analytics_reports_api.lib.inc, line 310 - Provides the Google Analytics Reports API Feed object type and associated methods.
Class
- GoogleAnalyticsReportsApiFeed
- GoogleAnalyticsReportsApiFeed class to authorize access to and request data from the Google Analytics Core Reporting API.
Code
protected function request($url, $params = array(), $headers = array(), $method = 'GET') {
$options = array(
'method' => $method,
'headers' => $headers,
);
if (count($params) > 0) {
if ($method == 'GET') {
$url .= '?' . drupal_http_build_query($params);
}
else {
$options['data'] = drupal_http_build_query($params);
}
}
$this->response = drupal_http_request($url, $options);
if ($this->response->code == '200') {
$this->results = json_decode($this->response->data);
}
else {
// Data is undefined if the connection failed.
if (!isset($this->response->data)) {
$this->response->data = '';
}
$error_vars = array(
'@code' => $this->response->code,
'@message' => $this->response->error,
'@details' => print_r(drupal_json_decode($this->response->data), TRUE),
);
$this->error = t('<strong>Code</strong>: @code, <strong>Error</strong>: @message, <strong>Message</strong>: <pre>@details</pre>', $error_vars);
watchdog('google analytics reports api', '<strong>Code</strong>: @code, <strong>Error</strong>: @message, <strong>Message</strong>: <pre>@details</pre>', $error_vars, WATCHDOG_ERROR);
}
}