I’m trying to read http://free.freeshoutcast.com:39072/7.html this page, I tried this code,
<?php
function curl_get_file_contents($URL)
{
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo curl_getinfo($c, CURLINFO_HTTP_CODE);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
echo curl_error($c);
curl_close($c);
if ($contents) return $contents;
else return FALSE;
}
echo curl_get_file_contents("http://free.freeshoutcast.com:39072/7.html");
?>
It’s working on localhost but, not working on server (godaddy/shared hosting)
-
curl is enabled
-
getting “couldn’t connect to host” error if I try to get a file with port number.
-
curl_get_file_contents(“http://www.google.com”); is working.
-
tried curl_setopt($c, CURLOPT_PORT, “39072”); //same error.
Where am I wrong?
Thanks.
EDIT: I’ve solved this problem by using yql, if it helps to somebody.
Your server most likely have a firewall rule blocking outgoing access for unusual ports.