init($url, $options); } public function init($url = false, $options = array(), $exec = false){ if( ! $url ){ return false; } $this->ch = curl_init( $url ); $this->setOptions( $options ); if ( $exec ){ $this->exec(); } } public function setOption($param = false, $value = false){ if ( ! $param && ! $value ){ return; } curl_setopt($this->ch, $param, $value); } public function setOptions( $options = array() ){ if ( ! empty( $options ) ){ foreach( $options as $key => $value ){ $this->setOption($key, $value); } } } public function exec(){ $this->result = curl_exec( $this->ch ); } public function getInfo($param){ return curl_getinfo($this->ch, $param); } public function setRequestMethod( $string ){ $request = strtolower( $string ); switch( $string ){ case("head"): break; case("post"): break; case("get"): break; case("put"): break; case("delete"): break; default: return false; } } public function setUserAgent($string){ return curl_setopt( $this->ch, CURLOPT_USERAGENT, $string ); } public function getStatusCode(){ return curl_getinfo( $this->ch, CURLOPT_HTTPHEADER); } public function __destruct(){ curl_close( $this->ch ); } }