I’m trying to open read a page on my own website for a search engine I’m trying to get working.
I’ve tried several ways of doing it:
file_get_contents
$temp = file_get_contents("http://www.mysite.com/example01/");
echo $temp;
returns:
Warning:
file_get_contents(http://www.mysite.com/example01/)
[function.file-get-contents]: failed
to open stream: A connection attempt
failed because the connected party did
not properly respond after a period of
time, or established connection failed
because connected host has failed to
respond. in
C:\inetpub\wwwroot\mysite\example01\temp.php
on line 66
curl
function curl($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true); // Display headers
curl_setopt($ch, CURLOPT_VERBOSE, true); // Display communication with server
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
print "<pre>\n";
print_r(curl_getinfo($ch)); // get error info
echo "\n\ncURL error number:" .curl_errno($ch); // print error info
echo "\n\ncURL error:" . curl_error($ch);
print "</pre>\n";
return curl_exec($ch);
curl_close($ch);
}
$temp = curl("http://www.mysite.com/example01/");
echo "'$temp'";
returns:
Array (
[url] => http://www.jlwarranty.com/example01/
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => 0
[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 )cURL error number:0
cURL error:
”
it takes about 30 seconds to get the page to reload.
cURL is enabled in php.ini, and so is allow_url_fopen.
Could it be a firewall issue? I had an issue a while ago for a client where I was unable to use cURL or the http stream wrapper to access an external resource, despite both being enabled. I was told by the hosting support that their firewall barred outbound http requests from their servers by default and they would need to add an exception for the site I was trying to access.
From the first error message it looks as if you’re running this on your own PC using IIS. Is there something in the IIS config or your computers setup that is stopping the server accessing remote resources?