- 论坛徽章:
- 0
|
require_once 'Zend/Feed.php';
// 取得最新的 Slashdot 头条新闻
try {
$slashdotRss = Zend_Feed::import('http://rss.slashdot.org/Slashdot/slashdot');
} catch (Zend_Feed_Exception $e) {
// feed 导入失败
echo "Exception caught importing feed: {$e->getMessage()}\n";
exit;
}
// 初始化保存 channel 数据的数组
$channel = array(
'title' => $slashdotRss->title(),
'link' => $slashdotRss->link(),
'description' => $slashdotRss->description(),
'items' => array()
);
// 循环获得channel的item并存储到相关数组中
foreach ($slashdotRss as $item) {
$channel['items'][] = array(
'title' => $item->title(),
'link' => $item->link(),
'description' => $item->description()
);
}
?>
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/32889/showart_460282.html |
|