Wonder if someone can help. I am using the cURL function to fetch the XML file into a string from an external server. But I am not getting anything . If I took this ‘s0000450_e.xml’ file and stored it on my host server, the content is returned. My code is as follows…
Yeah, but if it was throwing a fatal (function undefined) error without error reporting, he’d get a BLANK screen, and his string echos wouldnt appear either, not to mention that he wouldnt have been able to cURL the local file.
phpinfo() shows that cURL is enabled as seen here
cURL support enabled
cURL Information libcurl/7.20.0 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Here is my a snippet of my code and var_dump output is in the attached text file. Can’t make out what the output mean…
…
$pageurl = “http://dd.weatheroffice.ec.gc.ca/citypage_weather/xml/” . $province . “/” . $data_file;
print "
pageurl = ".$pageurl;
// Use cURL to fetch XML content into a PHP string variable.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $pageurl);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$xmlContents = curl_exec($ch);
Interestingly, I just looked godaddy’s policy on cURL up, and they removed the proxy requirement at the end of 2008 (but they’ve still got the servers running to accomodate legacy code)
khaunt, have you tried a standard file_get_contents on the URL?
Hmm… that is odd, as it should work the same… I suppose it’s possible that the server rejects connections that dont have a valid Agent code (Which is another CurlOpt), but i doubt it…
Is the server in question responding at a decent speed if you go to the file yourself? Is it slow?
Mittineague, I tried your code it didn’t work either. The content is blank.
Sorry Starlion I misunderstood your question. I don’t think my host uses a proxy as I was able to run the same code with another xml file from other server.