我不确定我的问题标题是否正确,但我尝试阅读一些RSS Feed(播客源)并使用相同的PHP代码,无法解析某些RSS源,并且其他人都被解析了。我不知道为什么,我也不知道如何找到错误。
我使用simplexml_load_file - 下面的代码:
<?php
//$xml = simplexml_load_file("http://hipsters.tech/feed/podcast/"); # it works
$xml = simplexml_load_file("https://jovemnerd.com.br/feed-nerdcast/"); # it doesn't works
# <channel> data
echo $xml->channel->title . "<br>\n";
echo $xml->channel->link . "<br>\n";
echo $xml->channel->language . "<br>\n";
echo $xml->channel->description . "<br>\n";
echo $xml->channel->image->url . "<br>\n";
$otherNode = $xml->channel->children('http://www.itunes.com/dtds/podcast-1.0.dtd');
echo $otherNode->author . "<br>\n";
echo "<br>#########################<br><br>\n";
# <item> data
for ($i = 0; $i < count($xml->channel->item); $i++ ) {
echo $xml->channel->item[$i]->title . "<br>\n";
echo $xml->channel->item[$i]->link . "<br>\n";
echo $xml->channel->item[$i]->pubDate . "<br>\n";
echo $xml->channel->item[$i]->description . "<br>\n";
echo "<br>#########################<br><br>\n";
}
?>
在我的代码中,您可以看到有2个链接,评论的链接有效,另一个无效。
我已经在堆栈和其他网站/论坛上看过其他帖子,但我真的不知道如何用一个代码解析任何RSS提要,没有头痛。
拜托,我需要一些帮助。谢谢。
修改
错误:
Warning: simplexml_load_file(https://jovemnerd.com.br/feed-nerdcast/): failed to open stream: Connection timed out in /var/www/html/thundercast-api/FeedReader.php on line 7
Warning: simplexml_load_file(): I/O warning : failed to load external entity "https://jovemnerd.com.br/feed-nerdcast/" in /var/www/html/thundercast-api/FeedReader.php on line 7
Notice: Trying to get property of non-object in /var/www/html/thundercast-api/FeedReader.php on line 10
Notice: Trying to get property of non-object in /var/www/html/thundercast-api/FeedReader.php on line 10
Notice: Trying to get property of non-object in /var/www/html/thundercast-api/FeedReader.php on line 11
Notice: Trying to get property of non-object in /var/www/html/thundercast-api/FeedReader.php on line 11
Notice: Trying to get property of non-object in /var/www/html/thundercast-api/FeedReader.php on line 12
Notice: Trying to get property of non-object in /var/www/html/thundercast-api/FeedReader.php on line 12
Notice: Trying to get property of non-object in /var/www/html/thundercast-api/FeedReader.php on line 13
Notice: Trying to get property of non-object in /var/www/html/thundercast-api/FeedReader.php on line 13
Notice: Trying to get property of non-object in /var/www/html/thundercast-api/FeedReader.php on line 14
Notice: Trying to get property of non-object in /var/www/html/thundercast-api/FeedReader.php on line 14
Notice: Trying to get property of non-object in /var/www/html/thundercast-api/FeedReader.php on line 14
#########################
Notice: Trying to get property of non-object in /var/www/html/thundercast-api/FeedReader.php on line 21
Notice: Trying to get property of non-object in /var/www/html/thundercast-api/FeedReader.php on line 21