GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Friday, April 15, 2011

Zend - Feed

<?php

require_once "Zend/Controller/Action.php";
require_once "Zend/Feed.php";

class IndexController extends Zend_Controller_Action{

    public function indexAction(){
        $this->_redirect('index/front');
    }
    public function frontAction(){
        $feed = Zend_Feed::import('http://images.apple.com/main/rss/hotnews/hotnews.rss');

        $output = '<h1>Title: '.$feed->title().'</h1>';
        $output .= '<h2>Link: '.$feed->link().'</h2>';
        $output .= '<h3>Description: '.$feed->description().'</h3>';
       
        foreach($feed as $item){
            $output .= '<div>';
            $output .= '<h2><a href="'.$item->link().'">'.$item->title().'</a></h2>';
            $output .= '<div>'.$item->description().'</div>';
            $output .= '</div>';
        }

        echo $output;

       // print xml document
       print $feed->saveXML();
    }

}

Share/Bookmark

No comments:

Post a Comment