Platinum Partner

Fetch Contents Via HTTP(S)

This is a simple class for fetch text via Http or Https protocal, using cURL.


set_url($url);
		}
	}
	function set_url($url){
		$url_array = parse_url($url);
		if ($url_array['scheme'] == 'https'){
			$this->secure = true;
		}else{
			$this->secure = false;
		}
		
		$this->url = $url;
		$host = $url_array['host'];
	}
	
	function set_useragent($useragent){
		$this->useragent = $useragent;
	}
	
	function set_header($header){
		if (is_array($header)){
			$this->header = $header;
		}else{
			$this->header = explode("\n", $header);
		}
	}
	
	function connect(){
		$this->curl = curl_init();
		curl_setopt($this->curl, CURLOPT_URL, $this->url);
		curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($this->curl, CURLOPT_HEADER, 0);
		if ($this->header){
			curl_setopt($this->curl, CURLOPT_HTTPHEADER, $this->header);
		}
		if ($this->secure){
			curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, FALSE);
			curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, 2);
		}
		
		$this->response = curl_exec($this->curl);
		$this->curl_info = curl_getinfo($this->curl);
	}
	
	function get_response_body(){
		return $this->response;
	}
	
	function get_response_code(){
		return $this->curl_info['http_code'];
	}
	
	function close(){
		curl_close($this->curl);
	}
}
?>
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}