[resolved] cURL is unable to resolve a URL
As this is on my server, on my laptop, I'd guess it's something I've failed to set up correctly. Here's the function I wrote:
And the $header array is:
However, file_get_contents also fails to get the file, so it's not just a cURL problem.
As this is on my server, on my laptop, I'd guess it's something I've failed to set up correctly. Here's the function I wrote:
PHP:
function get_file($url)
{
if(function_exists('curl_init'))
{
$options = array(CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "",
CURLOPT_USERAGENT => "xml-spider",
CURLOPT_AUTOREFERER => true,
CURLOPT_CONNECTTIMEOUT => 120,
CURLOPT_TIMEOUT => 120,
CURLOPT_MAXREDIRS => 10);
$ch = curl_init($url);
curl_setopt_array($ch, $options);
$content = curl_exec($ch);
$err = curl_errno($ch);
$errmsg = curl_error($ch);
$header = curl_getinfo($ch);
curl_close($ch);
$header['errno'] = $err;
$header['errmsg'] = $errmsg;
print_r($header); // Just for debugging
return $content;
}
else
{
return file_get_contents($url);
}
}
Code:
Array
(
[url] => http://www.barrucadu.co.uk/foaf.rdf
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0
[redirect_time] => 0
[errno] => 6
[errmsg] => Couldn't resolve host 'www.barrucadu.co.uk' // or whatever host I enter
)
However, file_get_contents also fails to get the file, so it's not just a cURL problem.
Last edited:






