Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1261604
  • 博文数量: 315
  • 博客积分: 10397
  • 博客等级: 上将
  • 技术积分: 3731
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-07 21:21
文章分类

全部博文(315)

文章存档

2015年(10)

2014年(3)

2013年(2)

2012年(8)

2011年(8)

2010年(29)

2009年(59)

2008年(77)

2007年(119)

分类:

2008-01-09 15:19:05

require_once 'Zend/Feed.php';

// 取得最新的 Slashdot 头条新闻
try {
    
$slashdotRss Zend_Feed::import('');
} 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()
        );
}

?>
阅读(698) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~