Im trying to run a simple curl script that just fetches a plain old website. Nothing fancy. Here is the script I am using:
$ch = curl_init('http://www.google.com');
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$html_data = curl_exec($ch);
curl_close($ch);
if (empty($html_data)) {
print "It broke!";
}
else {
print $html_data;
}
When I view the page I get the generic "The page cannot be displayed" error. But heres the funnything, when I run curl from the command line it fetches the entire site. Something funky is going on with curl and I cant quite put my finger on it. Was hoping to get a little help here.