Trying to get the content of the a certain URL using cURL and PHP. The code is supposed to run on the sourceforge.net project web hosting server.
code:
<?php
function get_data($url)
{
$ch = curl_init();
$timeout = 10;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$url1 = urlencode("http://www.google.com");
$url2 = "http://www.google.com";
$output = get_data($url2);
echo $output;
?>
I've checked that cURL is supported. But the above code is not working, the page is loading till timeout with no output. I've tried the encoded url as well. Why?
Error 503 Service Unavailable. PHP version 5.3.2