如何解决我如何获得最后一个RSS提要的内容
| 我有这个提要,我只需要解析最新的rss提要。我基本上想知道我是否可以获取最新的信息...我有这段代码可以帮助解析所有rss feed,但是我如何获取最新的$validCache = false;
if (file_exists(\'rss_cache.txt\')) {
$contents = file_get_contents(\'rss_cache.txt\');
$data = unserialize($contents);
if (time() - $data[\'created\'] < 24 * 60 * 60) {
$validCache = true;
$feed = $data[\'feed\'];
}
}
if (!$validCache) {
$feed = file_get_contents(\'http://someplace.com/feed/\');
$data = array (\'feed\' => $feed,\'time\' => time());
file_put_contents(\'rss_cache.txt\',serialize($data));
}
编辑:尝试
$xml = simplexml_load_file(\'http://blog.airdye.com/goodforwater/feed/\');
print_r($xml->channel->item[0]);
但说明为空白
SimpleXMLElement Object
(
[title] => one textile company gives away water filters and profits
[link] => http://blog.airdye.com/goodforwater/2011/05/20/one-textile-company-gives-away-water-filters-and-profits/
[comments] => http://blog.airdye.com/goodforwater/2011/05/20/one-textile-company-gives-away-water-filters-and-profits/#comments
[pubDate] => Fri,20 May 2011 20:09:31 +0000
[category] => Array
(
[0] => SimpleXMLElement Object
(
)
[1] => SimpleXMLElement Object
(
)
[2] => SimpleXMLElement Object
(
)
[3] => SimpleXMLElement Object
(
)
[4] => SimpleXMLElement Object
(
)
)
[guid] => http://blog.airdye.com/goodforwater/?p=2673
[description] => SimpleXMLElement Object
(
)
)
解决方法
答案已编辑:
<pre>
<?php
$xml = simplexml_load_file(\'http://wizardsoweb.com/feed\');
print_r($xml->channel->item[0]);
?>
</pre>
这是我正在阅读最新帖子的示例。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。