我试图弄清楚为什么在 SimplePie 网站上发布的用于显示多个提要的代码不起作用。具体来说,此代码示例:
http://simplepie.org/wiki/tutorial/sort_multiple_feeds_by_time_and_date
这是我正在使用的具体内容:
<?php
// Include the SimplePie library
// For 1.0-1.2:
#require_once('simplepie.inc');
require_once($_SERVER['DOCUMENT_ROOT']."/path/to/simplepie/autoloader.php");
// For 1.3+:
// Create a new SimplePie object
$feed = new SimplePie();
// Instead of only passing in one feed url, we'll pass in an array of three
$feed->set_feed_url(array(
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=1891&year=2013',
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=1313&year=2013',
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=5811&year=2013',
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=1044&year=2013',
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=1804&year=2013',
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=5512&year=2013',
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=5127&year=2013',
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=5128&year=2013',
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=1440&year=2013',
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=1085&year=2013',
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=1095&year=2013',
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=5395&year=2013',
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=5429&year=2013',
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=5482&year=2013',
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=1812&year=2013',
'http://apps.leg.wa.gov/billinfo/SummaryRss.aspx?bill=1457&year=2013'
));
// Initialize the feed object
$feed->init();
// This will work if all of the feeds accept the same settings.
$feed->handle_content_type();
// Begin our HTML markup
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Awesome feeds</title>
<style type="text/css">
h4.title {
/* We're going to add some space next to the titles so we can fit the 16x16 favicon image. */
background-color:transparent;
background-repeat:no-repeat;
background-position:0 1px;
padding-left:20px;
}
</style>
</head>
<body>
<div id="site">
<?php if ($feed->error): ?>
<p><?php echo $feed->error; ?></p>
<?php endif; ?>
<h1>Awesome feeds</h1>
<?php foreach ($feed->get_items() as $item): ?>
<div class="chunk">
<?php /* Here, we'll use the $item->get_feed() method to gain access to the parent feed-level data for the specified item. */ ?>
<h4 class="title" style="background-image:url(<?php $feed = $item->get_feed(); echo $feed->get_favicon(); ?>);"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h4>
<?php echo $item->get_content(); ?>
<p class="footnote">Source: <a href="<?php $feed = $item->get_feed(); echo $feed->get_permalink(); ?>"><?php $feed = $item->get_feed(); echo $feed->get_title(); ?></a> | <?php echo $item->get_date('j M Y | g:i a T'); ?></p>
</div>
<?php endforeach; ?>
</div>
</body>
</html>
这是我得到的 HTML 输出:
<body>
<div id="site">
<h1>Awesome feeds</h1>
<div class="chunk">
<h4 class="title" style="background-image:url(<br />
<b>Warning</b>: Favicon handling has been removed, please use your own handling in <b>/home/user/domain/library/SimplePie.php</b> on line <b>2946</b><br />
http://g.etfv.co/http%3A%2F%2Fapps.leg.wa.gov%2Fbillinfo%2Fsummary.aspx%3Fbill%3D1044%26amp%3Byear%3D2013);"><a href="<br />
<b>Fatal error</b>: Call to a member function get_base() on a non-object in <b>/home/user/domain/folder/subfolder/simplepie/library/SimplePie/Item.php</b> on line <b>167</b><br />
我尝试修改代码(例如,我可以不使用网站图标),但我总是收到致命错误消息,说“调用 [SimplePie 文件] 中非对象的成员函数 [填空] ”。
是否有更多最新代码可以用作构建处理多个提要的页面的模板?是什么破坏了 SimplePie 的工作?