Using curl with PHP is incredibly easy. Firstly you’ll need to make sure that you have the PHP curl library installed on your system. On Debian, this is as easy as apt-get install php5-curl
Now you can try the following:
<?php
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, “http://www.google.com/”);
curl_setopt($handle, CURLOPT_HEADER, 0);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($handle);
curl_close($handle);
print_r($output);
?>
You can also check http://uk.php.net/manual/en/function.curl-setopt.php to take a look at the other options that curl_setopt can take.
curl can also post data to the remote server via POST or GET and also has the ability to save and retransmit cookies.
You must be logged in to post a comment.