我正在尝试加载一个文件("http://feeds.artistdata.com/xml.shows/artist/AR-YX458DZO75EQACZ3/xml")使用file_get_contents,但我在5-10秒内收到一个错误。xml文件在浏览器中加载良好,如果我使用它的较小版本(在上面的url末尾添加"/foreture"),它使用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
有什么想法吗?我试过使用cURL,但当我这样做时,我只得到"第1行错误"。错误在不到10秒内显示,所以我无法想象这是超时问题,因为根据应用程序的不同,默认值通常为15秒或30秒。
//将其用于xml提要效果良好的
$load=file_get_contents('http://artistdata.sonicbids.com/ari-herstand/shows/xml/');
print_r($load);
-
file_get_contents()以字符串形式返回文件,从指定的偏移量开始,最大值为的len字节
-
如果最大长度小于零,或者偏移量超过流的长度,则会生成E_WARNING级别的错误。