protected function GAFeed::request in Google Analytics Reports 7
Same name and namespace in other branches
- 6 GAFeed.lib.inc \GAFeed::request()
Execute a query
1 call to GAFeed::request()
- GAFeed::query in ./
GAFeed.lib.inc - Public query method for all Data Export API features.
File
- ./
GAFeed.lib.inc, line 211 - 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
protected function request($url, $params = array(), $method = 'GET') {
$options = array(
'method' => $method,
);
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') {
// data is undefined if the connection failed.
if (!isset($this->response->data)) {
$this->response->data = '';
}
$error_msg = 'Code: !code - Error: !message - Message: !details';
$error_vars = array(
'!code' => $this->response->code,
'!message' => $this->response->error,
'!details' => strip_tags($this->response->data),
);
$this->error = t($error_msg, $error_vars);
watchdog('google analytics reports', $error_msg, $error_vars, WATCHDOG_ERROR);
}
}