Public Member Functions | |
| setConfig ($config=array()) | |
| connect ($host, $port=80, $secure=false) | |
| write ($method, $url, $http_ver= '1.1', $headers=array(), $body= '') | |
| read () | |
| close () | |
| getErrno () | |
| getError () | |
| getInfo ($opt=0) | |
Protected Member Functions | |
| _getResource () | |
Protected Attributes | |
| $_config = array() | |
| $_resource | |
Definition at line 34 of file Curl.php.
| _getResource | ( | ) | [protected] |
| close | ( | ) |
Close the connection to the server
Definition at line 140 of file Curl.php.
00141 { 00142 curl_close($this->_getResource()); 00143 $this->_resource = null; 00144 return $this; 00145 }
| connect | ( | $ | host, | |
| $ | port = 80, |
|||
| $ | secure = false | |||
| ) |
Connect to the remote server
| string | $host | |
| int | $port | |
| boolean | $secure |
Definition at line 63 of file Curl.php.
00064 { 00065 //curl_setopt(); 00066 if (isset($this->_config['timeout'])) { 00067 curl_setopt($this->_getResource(), CURLOPT_TIMEOUT, $this->_config['timeout']); 00068 } 00069 if (isset($this->_config['maxredirects'])) { 00070 curl_setopt($this->_getResource(), CURLOPT_MAXREDIRS, $this->_config['maxredirects']); 00071 } 00072 if (isset($this->_config['proxy'])) { 00073 curl_setopt ($this->_getResource(), CURLOPT_PROXY, $this->_config['proxy']); 00074 } 00075 00076 return $this; 00077 }
| getErrno | ( | ) |
Definition at line 155 of file Curl.php.
00156 { 00157 return curl_errno($this->_getResource()); 00158 }
| getError | ( | ) |
Definition at line 160 of file Curl.php.
00161 { 00162 return curl_error($this->_getResource()); 00163 }
| getInfo | ( | $ | opt = 0 |
) |
Get information regarding a specific transfer
| int | $opt CURLINFO option |
Definition at line 171 of file Curl.php.
00172 { 00173 return curl_getinfo($this->_getResource(), $opt); 00174 }
| read | ( | ) |
Read response from server
Definition at line 122 of file Curl.php.
00123 { 00124 $response = curl_exec($this->_getResource()); 00125 00126 // Remove 100 and 101 responses headers 00127 if (Zend_Http_Response::extractCode($response) == 100 || 00128 Zend_Http_Response::extractCode($response) == 101) { 00129 $response = preg_split('/^\r?$/m', $response, 2); 00130 $response = trim($response[1]); 00131 } 00132 00133 return $response; 00134 }
| setConfig | ( | $ | config = array() |
) |
| write | ( | $ | method, | |
| $ | url, | |||
| $ | http_ver = '1.1', |
|||
| $ | headers = array(), |
|||
| $ | body = '' | |||
| ) |
Send request to the remote server
| string | $method | |
| Zend_Uri_Http | $url | |
| string | $http_ver | |
| array | $headers | |
| string | $body |
Definition at line 89 of file Curl.php.
00090 { 00091 if ($url instanceof Zend_Uri_Http) { 00092 $url = $url->getUri(); 00093 } 00094 // set url to post to 00095 curl_setopt($this->_getResource(), CURLOPT_URL, $url); 00096 curl_setopt($this->_getResource(), CURLOPT_RETURNTRANSFER, true); 00097 if ($method == Zend_Http_Client::POST) { 00098 curl_setopt($this->_getResource(), CURLOPT_POST, true); 00099 curl_setopt($this->_getResource(), CURLOPT_POSTFIELDS, $body); 00100 } 00101 elseif ($method == Zend_Http_Client::GET) { 00102 curl_setopt($this->_getResource(), CURLOPT_HTTPGET, true); 00103 } 00104 00105 if( is_array($headers) ) { 00106 curl_setopt($this->_getResource(), CURLOPT_HTTPHEADER, $headers); 00107 } 00108 00109 curl_setopt($this->_getResource(), CURLOPT_HEADER, true); 00110 curl_setopt($this->_getResource(), CURLOPT_SSL_VERIFYPEER, 0); 00111 curl_setopt($this->_getResource(), CURLOPT_SSL_VERIFYHOST, 0); 00112 00113 00114 return $body; 00115 }
1.5.8