
 Nigel Johnson - 2014-01-11 13:54:30
Admittedly, I've only tested this in PHP 5.4, but you can use streams instead of cURL...
	public function curl_request($url, $method, $postvals) {
		if (is_callable ( 'curl_init' )) {
			$ch = curl_init ( $url );
			if ($method == "POST") {
				$options = array (
						CURLOPT_POST => 1,
						CURLOPT_POSTFIELDS => $postvals,
						CURLOPT_RETURNTRANSFER => 1
				);
			} else {
				$options = array (
						CURLOPT_RETURNTRANSFER => 1
				);
			}
			curl_setopt_array ( $ch, $options );
			if ($this->header) {
				curl_setopt ( $ch, CURLOPT_HTTPHEADER, array (
						$this->header . $postvals
				) );
			}
			$response = curl_exec ( $ch );
			curl_close ( $ch );
			// print_r($response);
			return $response;
		} else {
			$options = array (
					"http" => array (
							"method" => $method
					)
			);
			if ($method == "POST" && strlen ( @$postvals )) {
				$options["http"]["content"] = $postvals;
			}
			if ($this->header) {
				$options["http"]["header"] = $this->header . $postvals;
			}
			$context = stream_context_create ( $options );
			$result = file_get_contents ( $url, false, $context );
			if ($result === false) {
				return false;
			}
			return $result;
		}
	}