Tuesday, September 9, 2008

CURL with HTTP Authentication

// HTTP authentication
$site_url = "http://evergreenphp.com";
$ftp_username = "onetwothree";
$ftp_password = "threetwoone";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $site_url);
curl_setopt($ch, CURLOPT_USERPWD, $ftp_username.":".$ftp_password);
$result = curl_exec($ch);
print_r(curl_getinfo($ch));
echo "\n\ncURL error number:" .curl_errno($ch);
echo "\n\ncURL error:" . curl_error($ch);
// ...close cURL handle ($ch) below
curl_close($ch);
?>

No comments:

Popular Posts