为什么simplexml_load_file()不能使用一些xml rss


why simplexml_load_file() can not use some xml rss?

我在函数中使用simplexml_load_file(),它适用于每一个成功的rss但我对这个网站的Rss有问题例如:

http://www.bignewsnetwork.com/index.php/nav/rss/4a6d634cbccbbfe2

我也无法使用file_get_contents()获取此页面源;

有我的错误:

Warning: simplexml_load_file(http://www.bignewsnetwork.com/index.php/nav/rss/4a6d634cbccbbfe2) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in C:'wamp'www'php'44'xml.php on line 5
Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://www.bignewsnetwork.com/index.php/nav/rss/4a6d634cbccbbfe2" in C:'wamp'www'php'44'xml.php on line 5
bool(false)

如何使用此RSS?请帮帮我。

正如我在评论中所说:

HTTP/1.1 403禁止您没有访问该资源的权限。

然而,我可以从浏览器中点击它,所以它可能与用户代理(或它试图验证的其他HTTP标头)有关。在这种情况下,您可以使用curl来提取数据,并提供您喜欢的任何用户代理(或其他必要的头)。

$ch = curl_init('http://www.bignewsnetwork.com/index.php/nav/rss/4a6d634cbccbbfe2');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Identify the rquest User Agent as Chrome - any real browser, or perhaps any value may work
// depending on the resource you are trying to hit
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36');

$feed = curl_exec($ch);
$rss = new SimpleXMLElement($feed);