protected function GAFeed::request in Google Analytics Counter 7.2
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 216 - 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') {
$data = '';
if (count($params) > 0) {
if ($method == 'GET') {
$url .= '?' . http_build_query($params, '', '&');
}
else {
$data = http_build_query($params, '', '&');
}
}
$headers = array();
$this->response = drupal_http_request($url, $headers, $method, $data);
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_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 Counter', $error_msg, $error_vars, WATCHDOG_ERROR);
}
}