• i believe in what i do •
sirimalla_savechild_1098

Read Rss/Atom feed using php without allow_url_fopen

| 0 Comments | 0 TrackBacks

Web feed is a data format used to provide updates for blog or website. Most common types of feed are Rss and Atom. In this article you will learn how to read these feeds using php.

As we know that feeds are generated by using XML, so generic way to parse it by using php5 simplexml_load_file function. But we have to write different functions to parse different types of feed and versions. 
To do this in simple way there is a php class named SimplePie

Php code to read Rss/Atom feed using SimplePie
set_feed_url($url);
  $feed->enable_cache(false);
  $feed->set_output_encoding('Windows-1252');
  $feed->init();
  $SiteTitle= $feed->get_title();
  $SiteDesc=$feed->get_description();
  $itemCount=$feed->get_item_quantity();
  $items=$feed->get_items();
  foreach($items as $item)
  {
  $Url=$item->get_permalink();
  $Title=$item->get_title();
  $Desc=$item->get_description();
  $Date=$item->get_date();
  if ($category = $item->get_category())
  $CatName = $category->get_label();
  }
  ?>

No TrackBacks

TrackBack URL: http://sirimalla.com/mt5/mt-tb.cgi/87

Leave a comment