public function execute()
{
// Set query data if there is any
if (count($this->fields) > 0) {
if ($this->isPost()) {
$this->setOption(CURLOPT_POSTFIELDS, $this->fields);
} else {
$url = $this->options[CURLOPT_URL] . '?' . http_build_query($this->fields);
$this->setOption(CURLOPT_URL, $url);
}
}
$this->response = curl_exec($this->curl);
if ($this->response === false) {
$this->showError();
}
// If the CURLOPT_RETURNTRANSFER option is set, get the response body and parse the headers.
if (isset($this->options[CURLOPT_RETURNTRANSFER]) && $this->options[CURLOPT_RETURNTRANSFER] == true) {
$this->headerSize = $this->getInfo(CURLINFO_HEADER_SIZE);
if ($this->options[CURLOPT_HEADER]) {
$this->header = substr($this->response, 0, $this->headerSize);
$this->body = substr($this->response, $this->headerSize);
$this->parseHeaders();
} else {
$this->body = $this->response;
}
}
return $this->response;
}