Zend Feed (Zend_Feed) example / RSS feeds tutorial
Requeiste : library folder from Zend framework ( Here is the URL : http://framework.zend.com/download/current/)
Create a folder Zfeeds and put library folder inside it.
We are trying to get feeds from http://news.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss091.xml
Here is the entire script : script name zf_feeds.php
error_reporting(E_ALL|E_STRICT);
date_default_timezone_set('Europe/London');
set_include_path('.' . PATH_SEPARATOR . './library/'
. PATH_SEPARATOR . './application/models/'
. PATH_SEPARATOR . './application/lib/'
. PATH_SEPARATOR . get_include_path());
include "Zend/Loader.php";
Zend_Loader::registerAutoload();
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Http_Client_Adapter_Proxy');
Zend_Loader::loadClass('Zend_Feed');
$url = "http://news.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss091.xml";
try {
$rss = Zend_Feed::import($url);
} catch (Zend_Feed_Exception $e) {
echo "Error while importing feed: {$e->getMessage()}\n";
exit;
}
$output = '
- ';
- '.$title.''.
''.$date.'';
/*if($this->showDescription)
{
$output .= ''.$post->description().'';
}
if($this->showContent)
{
$output .= ''.$post->content().'';
}
$output .= ' ';*/
$i = 0;
foreach($rss as $post)
{
$title = $post->title();
$date = strftime("%B %e, %Y", strtotime($post->pubDate()));
$link = $post->link();
$output .= '
#if(++$i == $this->count) break;
}
$output .= '
echo $output;
Enjoy and Have fun!!! . Do post if any problems