/** * _curl * * @param mixed $url * @return mixed */ protected function _curl($url) { $curl = new \Nodes\Curl($url, array(CURLOPT_CONNECTTIMEOUT => 4)); return $curl->get()->getResponseBody(); }
protected function _get($params) { if (static::$_embedded) { return array(); } $etag = isset($params['etag']) ? $params['etag'] : null; unset($params['etag']); $request = new \Nodes\Curl(); $request->setOption(CURLOPT_URL, $this->_buildRequestURI($params)); if (!empty($this->_settings['curl_headers'])) { $request->setOption($this->_settings['curl_headers']); } // Suport 304 Not Modified using etag if ($etag || isset($this->_settings['etag'])) { $request->setOption(CURLOPT_HTTPHEADER, array('If-None-Match: ' . ($etag ?: $this->_settings['etag']))); } $request->get(); $responseBody = $request->getResponseBody(); $this->_lastHeaders = $request->getResponseHeaders(); if (isset($responseBody['error'])) { throw new Exception($responseBody['error']['message'], $responseBody['error']['code']); } return $request; }