我试图用file_get_contents加载一个文件("http://feeds.artistdata.com/xml.shows/artist/AR-YX458DZO75EQACZ3/xml"),但是我在5-10秒内得到了一个错误。xml文件在浏览器中加载得很好,如果我使用它的较小版本(在上面的url末尾添加"/future“),它在file_get_contents中加载得也很好。
脚本是:
$file = "http://feeds.artistdata.com/xml.shows/artist/AR-YX458DZO75EQACZ3/xml";
$data = file_get_contents($file);出现以下两个错误之一:
Warning: file_get_contents("http://feeds.artistdata.com/xml.shows/artist/AR-YX458DZO75EQACZ3/xml") [function.file-get-contents]: failed to open stream: HTTP request failed! in MY_PHP_SCRIPT.php on line 2或者:
Warning: file_get_contents("http://feeds.artistdata.com/xml.shows/artist/AR-YX458DZO75EQACZ3/xml") [function.file-get-contents]: failed to open stream: Connection timed out in MY_PHP_SCRIPT.php on line 2有什么想法吗?我已经尝试过using cURL instead,但是当我这样做的时候,我只得到"Error on line 1“。错误在不到10秒内出现,所以我无法想象这是一个超时问题,因为这些默认值通常是15秒或30秒,具体取决于应用程序。
发布于 2012-01-28 13:12:35
//将它用于xml提要可以很好地工作
$load = file_get_contents('http://artistdata.sonicbids.com/ari-herstand/shows/xml/');
print_r($load);
发布于 2012-01-28 15:24:40
https://stackoverflow.com/questions/9042948
复制相似问题