Zend Framework之feed实例
时间:2008-01-09 来源:panzt
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()
);
}
?>
// 取得最新的 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()
);
}
?>
相关阅读 更多 +