iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (34)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

May 22, 2008
How to Create an Ajax Autocomplete Text Field: Part 7
WebReference.com
 
May 22, 2008
Poll: Have you taken formal Web design, HTML, or CSS classes?
About
 
May 21, 2008
Rails For Beginners: All You Need To Know!
SitePoint
 
May 21, 2008
Web Host Reviews - 18 New Reviews
About
 
May 21, 2008
Pop-up Checkbox Navbar
EarthWeb.com
 
May 20, 2008
Write valid XML by writing your own schemas
About
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /PHP /XML and PHP

Displaying RSS Feeds on your Website Using PHP 

  Views:    5243
  Votes:    1
by Mikel Beck 1/05/06 Rating: 

Synopsis:

By using RSS and the MagpieRSS toolkit, you can import data from another web site or news source and display that information on your own site.
Pages: 
The Article

These days everybody wants to have fresh content on their web site. Search engines like to see dynamic web pages, where the content is updated on a regular basis. Static pages that have information that doesn't change are not only boring, but less likely to be visited by a search engine spider than a page that changes every time it is displayed.

By using RSS and the MagpieRSS toolkit, you can import data from another web site or news source and display that information on your own site.

First, download the MagpieRSS kit from http://magpierss.sourceforge.net.

Next, unpack the archive, into a directory off your root on your web site called "rss".

Then, create a directory off your root called "cache". CHMOD this directory to 777.

You'll need to know the URL for the feed that you want to display. You can find this by searching for "RSS feed" in Google, or by going to one of the many sites that allow you to search thrown various sources for feeds. Syndic8.com is one, for example.

To display data from a single source, you can use code similar to this:

require_once('rss/rss_fetch.inc');

$news_feed = '';

error_reporting(E_ERROR);

$rss = fetch_rss("http://www.url-of-the-rss-feed.com");

$items = array_slice($rss->items, 0);

foreach ($items as $item ) {

$news_feed .= '' . $item['title'] . '' . $item['summary'] . ''; }

echo $news_feed;

MagpieRSS not only decodes the data, but it will also cache the data so it will retrieve news articles only once per hour.

Utilizing RSS in this fashion will allow your web site to have fresh content displayed constantly, and will (hopefully!) keep the search engine spiders interested in your site. The more the spiders index your site, the more pages you will have listed in the search engines. And with more pages listed in the search engine indexes you have a much better chance of attracting people to your web site.


About The Author
Copyright © 2005 by Mikel Beck. Mikel Beck is the owner of a number of web sites, the latest being The Happy Hour Pub.

Pages: 

Similar/related articles:


 
  Sponsors