Quantcast

RSS feeds – Adding a Feed to a Website Using PHP

Get the WebProNews Newsletter:
[ Search]

Adding an rss feed to your website is not as difficult as most people believe.

The great thing about adding RSS feeds to your website is that the feed can keep your page content updated automatically since you are ‘streaming’ information directly from another website to your page!

The method of adding RSS feeds discussed below involves the use of PHP and HTML.

To get started with streaming an RSS feed, you need to download a package called RSS2HTML which makes it easy to add feeds to your website.

You can download the RSS2HTML package from http://www.feedforall.com/download.htm Once the files are unzipped, upload the php file rss2html.php to your server.

RSS2HTML uses templates to define how the news feed should be displayed, so you will also have to upload the template file included in the package to your server (template1.html). Once those files have been uploaded, loading an RSS file is easy!

Choose the HTML file you would like the RSS file to be loaded in, and rename the file to have an extension of .php instead of .htm Next, include the code snippet below in your new php file *MAKE SURE THAT THE CODE IS ON ONE LINE*

<?php include('http://www.yourserver.com/rss2html.php?XMLFILE=http://ww w.searchenginewatch.com/sew.xml&TEMPLATE=http://www.yourserver.or g/template1.html&MAXITEMS=20 target="_blank">'); ?>

Let me explain what’s going on in the code above; the first URL rss2html.php, is the path where you have uploaded your rss2html file;

the XMLFILE variable is the URL of the RSS news feed,

the TEMPLATE variable contains the URL of the template which defines how the news feed should be displayed. You can edit this in notepad if you want.

The MAXITEM variable defines how many items in the RSS feed should be displayed. (For more information about items in news feeds, consult the ‘Making an RSS feed’ article)

That’s all there is to it! The php file should read the XML RSS file and display the contents using the template file.

As for where to find RSS feeds to add to your website? The main place I head to find RSS feeds is the Octora RSS feed search engine at http://www.octora.com You can type in a keyword; and hundreds if not thousands of feeds are usually produced for the keyword. Other places also include Bloglines and Technorati.

That said, go on and have fun adding feeds to your website!

Tag:

Add to Del.icio.us | Digg | Yahoo! My Web | Furl

Bookmark WebProNews:

Kevin Allman is webmaster with over ten years Internet experience. He runs a Search Engine Optimization website at http://www.pzeta.org/seo_global/ which contains many articles on how to optimize your website. He also has been involved with search engine technology and has developed mini search engines throughout the past few years.

RSS feeds – Adding a Feed to a Website Using PHP
About Kevin Allman
Kevin Allman is webmaster with over ten years Internet experience. He runs a Search Engine Optimization website at http://www.pzeta.org/seo_global/ which contains many articles on how to optimize your website. He also has been involved with search engine technology and has developed mini search engines throughout the past few years. WebProNews Writer
Top Rated White Papers and Resources
  • Robin

    Can you limit the frequency of updating an RSS feed on a web site so that it’s maybe once daily vs. instantly?

  • http://www.pselvam.com/ pannerselvam

    Hi  thanks

  • http://www.2levelsabove.com Scott

    Thanks again. This is good because now I can add RSS feeds to my site :)

     

  • http://www.codepal.co.in Guest

    Hi i’ve added as per the steps u’ve mentioned but im getting error like ‘failed to open stream’.
    what could be the reason?
    my page is
    http://www.codepal.co.in/TestFeed.php
    please reply me @ binobose@gmail.com

  • http://www.basicfinancialiq.com Guest

    Are there any video only RSS feeds that are available?

  • pwpradeep1

    Hello ,

    How to integrate dynamic data to RSS Feeds with PHP ?

    For details, please click here.

    http://www.phpbuilder.com/board/showthread.php?p=10928913#post10928913

  • http://www.edealz.co.uk edealz

    Hi,
    I want to use this to display the rss content on my homepage – displaying the latest post from a blog.
    I only want it to display the title of the the most recent post and have the link through to the blog post.
    Is this possible with rss2html?

  • http://www.blastcasta.com/ News Widget

    Thanks. There’s also a way to add fresh feed content to your website in the HTML using the JavaScript news widgets from BlastCasta.com. They’re customizable too.

  • http://asobh.com/mbb ASOBH

    ?????????? ????? ?????? ????? ??????? ??? ??????? ????? ???? ????? ???????

  • http://www.1clickproducts.com/ sampth@sales pages

    Is there way using html other than PHP ?

    thanks

  • http://www.aspstudios.com Alex

    I found this article related to displaying WordPress RSS feeds on an external website.

    However, the above script requires the RSS to be in a .XML file.

    How do you use RSS2HTML with wordpress RSS feed (example:http://example.com/?feed=rss)

  • http://seo seo

    I love what you guys are up too. This kind of clever work and reporting! Keep up the good works guys I’ve you guys to my personal blogroll.

  • Aneeq

    There are several ways to read RSS feed in PHP, but this one is surely one of the easiest.

    channel->item as $entry) {
    echo “link’ title=’$entry->title’>” . $entry->title . “”;
    }

    ?>

    Source:
    http://phphelp.co/2012/04/23/how-to-read-rss-feed-in-php/
    OR
    http://addr.pk/a0401

  • http://www.ypages.pk Mazhar Shahzad

    Hello friends any one can help me to add RSS feeds in my Yellow Pages website