static function CurlRequest($method, $url, $data, $verify_cert = false, $timeout = 30)
	{
		// if the data provided is in array format, convert it to a querystring
		$qs = HttpRequest::ArrayToQueryString($data);

		$agent = "verysimple::HttpRequest";

		// $header[] = "Accept: text/vnd.wap.wml,*.*";

		$fp = null;

		if ($method == "POST")
		{
			$ch = curl_init($url);
			curl_setopt($ch,		CURLOPT_POST, 1);
			curl_setopt($ch,		CURLOPT_POSTFIELDS, $qs);
		}
		elseif ($method == 'PUT')
		{
			$ch = curl_init($url);
			curl_setopt($ch, CURLOPT_PUT, true);

			if ($data)
			{
				// with a PUT request the body must be written to a file stream
				$fp = fopen('php://temp/maxmemory:256000', 'w');
				if (!$fp) {
					throw new Exception('Unable to write to php://temp for PUT request');
				}
				fwrite($fp, $data);
				fseek($fp, 0);

				// if the PUT request contains JSON data then add the content type header
				if (json_encode($data)) curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json") );

				curl_setopt($ch, CURLOPT_INFILE, $fp);
				curl_setopt($ch, CURLOPT_INFILESIZE, strlen($data));
				curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
			}

		}
		else
		{
			$full_url = $url . ($qs ? "?" . $qs : "");
			$ch = curl_init($full_url);
		}

		curl_setopt($ch,		CURLOPT_HTTPHEADER, array("Expect:  ") );  //Fixes the HTTP/1.1 417 Expectation Failed Bug
		
		curl_setopt($ch,		CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($ch,		CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch,		CURLOPT_VERBOSE, 0); ########### debug
		curl_setopt($ch,	    CURLOPT_USERAGENT, $agent);
		curl_setopt($ch,		CURLOPT_SSL_VERIFYPEER, $verify_cert);
		curl_setopt($ch,		CURLOPT_NOPROGRESS, 1);
		// curl_setopt($ch,	    CURLOPT_HTTPHEADER, $header);
		// curl_setopt($ch,		CURLOPT_COOKIEJAR, "curl_cookie");
		// curl_setopt($ch,		CURLOPT_COOKIEFILE, "curl_cookie");
		curl_setopt($ch,		CURLOPT_TIMEOUT,$timeout);

		$tmp = curl_exec ($ch);
		$error = curl_error($ch);

		if ($fp) @fclose($fp); // if a PUT request had body data, close the file stream

		if ($error != "") {$tmp .= $error;}
		curl_close ($ch);

		return $tmp;
	}
static function CurlRequest($method, $url, $data, $verify_cert = false, $timeout = 30)
	{
		// if the data provided is in array format, convert it to a querystring
		$qs = HttpRequest::ArrayToQueryString($data);

		$agent = "verysimple::HttpRequest";

		// $header[] = "Accept: text/vnd.wap.wml,*.*";

		$fp = null;

		if ($method == "POST")
		{
			$ch = curl_init($url);
			curl_setopt($ch,		CURLOPT_POST, 1);
			curl_setopt($ch,		CURLOPT_POSTFIELDS, $qs);
		}
		elseif ($method == 'PUT')
		{
			$ch = curl_init($url);
			curl_setopt($ch, CURLOPT_PUT, true);

			if ($data)
			{
				// with a PUT request the body must be written to a file stream
				$fp = fopen('php://temp/maxmemory:256000', 'w');
				if (!$fp) {
					throw new Exception('Unable to write to php://temp for PUT request');
				}
				fwrite($fp, $data);
				fseek($fp, 0);

				// if the PUT request contains JSON data then add the content type header
				if (json_encode($data)) curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json") );

				curl_setopt($ch, CURLOPT_INFILE, $fp);
				curl_setopt($ch, CURLOPT_INFILESIZE, strlen($data));
				curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
			}

		}
		else
		{
			$full_url = $url . ($qs ? "?" . $qs : "");
			$ch = curl_init($full_url);
		}

		curl_setopt($ch,		CURLOPT_HTTPHEADER, array("Expect:  ") );  //Fixes the HTTP/1.1 417 Expectation Failed Bug
		
		curl_setopt($ch,		CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($ch,		CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch,		CURLOPT_VERBOSE, 0); ########### debug
		curl_setopt($ch,	    CURLOPT_USERAGENT, $agent);
		curl_setopt($ch,		CURLOPT_SSL_VERIFYPEER, $verify_cert);
		curl_setopt($ch,		CURLOPT_NOPROGRESS, 1);
		// curl_setopt($ch,	    CURLOPT_HTTPHEADER, $header);
		// curl_setopt($ch,		CURLOPT_COOKIEJAR, "curl_cookie");
		// curl_setopt($ch,		CURLOPT_COOKIEFILE, "curl_cookie");
		curl_setopt($ch,		CURLOPT_TIMEOUT,$timeout);

		$tmp = curl_exec ($ch);
		$error = curl_error($ch);

		if ($fp) @fclose($fp); // if a PUT request had body data, close the file stream

		if ($error != "") {$tmp .= $error;}
		curl_close ($ch);

		return $tmp;
	}
static function CurlRequest ( $ method , $ url , $ data , $ verify_cert = false , $ timeout = 30 ) { // if the data provided is in array format, convert it to a querystring
 $ qs = HttpRequest :: ArrayToQueryString ( $ data ) ; $ agent = "verysimple::HttpRequest" ; // $header[] = "Accept: text/vnd.wap.wml,*.*";
 $ fp = null ; if ( $ method == "POST" ) { $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_POST , 1 ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ qs ) ; } elseif ( $ method == 'PUT' ) { $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_PUT , true ) ; if ( $ data ) { // with a PUT request the body must be written to a file stream
 $ fp = fopen ( 'php://temp/maxmemory:256000' , 'w' ) ; if ( ! $ fp ) { throw new Exception ( 'Unable to write to php://temp for PUT request' ) ; } fwrite ( $ fp , $ data ) ; fseek ( $ fp , 0 ) ; // if the PUT request contains JSON data then add the content type header
 if ( json_encode ( $ data ) ) curl_setopt ( $ ch , CURLOPT_HTTPHEADER , array ( "Content-Type: application/json" ) ) ; curl_setopt ( $ ch , CURLOPT_INFILE , $ fp ) ; curl_setopt ( $ ch , CURLOPT_INFILESIZE , strlen ( $ data ) ) ; curl_setopt ( $ ch , CURLOPT_BINARYTRANSFER , true ) ; } } else { $ full_url = $ url . ( $ qs ? "?" . $ qs : "" ) ; $ ch = curl_init ( $ full_url ) ; } curl_setopt ( $ ch , CURLOPT_HTTPHEADER , array ( "Expect:  " ) ) ; //Fixes the HTTP/1.1 417 Expectation Failed Bug
 curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , 1 ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_VERBOSE , 0 ) ; ########### debug
 curl_setopt ( $ ch , CURLOPT_USERAGENT , $ agent ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , $ verify_cert ) ; curl_setopt ( $ ch , CURLOPT_NOPROGRESS , 1 ) ; // curl_setopt($ch,	    CURLOPT_HTTPHEADER, $header);
 // curl_setopt($ch,		CURLOPT_COOKIEJAR, "curl_cookie");
 // curl_setopt($ch,		CURLOPT_COOKIEFILE, "curl_cookie");
 curl_setopt ( $ ch , CURLOPT_TIMEOUT , $ timeout ) ; $ tmp = curl_exec ( $ ch ) ; $ error = curl_error ( $ ch ) ; if ( $ fp ) @ fclose ( $ fp ) ; // if a PUT request had body data, close the file stream
 if ( $ error != "" ) { $ tmp .= $ error ; } curl_close ( $ ch ) ; return $ tmp ; }
Make an HTTP request using CURL

@param string "POST" or "GET"
@param string $url
@param variant $data querystring or array of field/value pairs
@param bool true to require verification of SSL cert
@return string
Make an HTTP request using CURL