/** * Make a request to the database webservice. * * @param string $method The HTTP method to use [POST, PUT, GET]. * @param string $url The URL to send the request to. * @param array|string $data The data to send along with the request. * * @return mixed the answer from the database webservice */ protected function request($method, $url, $data = null) { switch ($method) { case "POST": $this->curl->setOption(CURLOPT_POST, 1); if ($data) { $this->curl->setOption(CURLOPT_POSTFIELDS, $data); } break; case "PUT": $this->curl->setOption(CURLOPT_CUSTOMREQUEST, "PUT"); if ($data) { $this->curl->setOption(CURLOPT_POSTFIELDS, http_build_query($data)); } break; default: if ($data) { $url = sprintf("%s?%s", $url, http_build_query($data)); } } $this->curl->setOption(CURLOPT_URL, $url); $this->curl->setOption(CURLOPT_RETURNTRANSFER, 1); $result = $this->curl->execute(); $this->curl->close(); return $result; }
public function execute($version, $query) { $url = $this->buildQuery($version, $query); if (!empty($url)) { $curlH = new CurlHelper($url, '', '', false, $this->_token); $curlH->execute(); $extractedObj = $this->readXml($curlH); if (!empty($extractedObj)) { $this->_extractedResponse = $extractedObj; } else { $this->_isError = true; $this->_errorMessage = "could not extract response"; } } }