How to Generate an RSS Feed using Php

2 views
Skip to first unread message

WebmasterHub .net

unread,
Jan 9, 2010, 3:00:46 AM1/9/10
to Web Programing & SEO
The following describes how to generate an RSS 2.0 compatible feed from a Php Script.  the process utilises the free Php RSS2Writer Class written by Daniel Soutter.  Examples are provided to create an RSS feed that includes optional information such as copyright, author, and channel/item categories.  The Class allows the RSS Feed XML to be rendered by a browser or RSS Reader, as well as the option to output the RSS feed to a file if required.

For more detailed information, usage instructions and a free download of the RSS2Writer Package containing the class file and sample controller, see Php RSS2Writer (v2.0) - Generate RSS 2.0 Feed - Usage Instructions & Download.

Generate an RSS Feed using the Php RSS2Writer Class:


1. Include and initiate the RSS2Writer Class

require_once("RSS2Writer.php");
$rss2_writer = new RSS2Writer('Feed Title', 'Feed Description', 'feed url');

2. Add additional information to the Feed Channel

$rss2_writer->addElement('copyright', '(c) Daniel Soutter 2010');

3. Add Items to the Feed

$rss2_writer->addItem('item title', 'item content/description', 'item url');

3.1 Add Additional information to an item (most recent)

$rss2_writer->addCategory("Free Php Script");
$rss2_writer->addCategory("RSS 2.0 Feed Generator");

4. Output the RSS 2.0 compatible Feed XML

echo $rss->getXML();


When the php script is accessed using a web browser, the result will be an RSS 2.0 compatible feed, which can the be subscribed to, or submitted to search engines as a site map. 

Note: To add additional information to the feed channel, you need to call the addElement / addCategory functions before adding items to the feed.  To add additional information to a specific item in the RSS feed, call the functions after adding the items to the feed.  The additional elements will be added to the item most recently added to the feed.






-----------------------------------------------
Generate RSS Feed using Php
Free Download Php RSS Writer
Message has been deleted
Message has been deleted

Daniel

unread,
Jan 9, 2010, 4:47:02 AM1/9/10
to Web Programming & SEO
http://forums.digitalpoint.com/showthread.php?t=32265&page=2

On Jan 9, 8:36 pm, Daniel <webmasterhub....@gmail.com> wrote:
> http://www.webmaster-talk.com/php-forum/195650-how-generate-rss-feed-...
>
> On Jan 9, 8:05 pm, Daniel <webmasterhub....@gmail.com> wrote:
>
> >http://www.gidforums.com/t-22454.html
>
> > On Jan 9, 7:00 pm, "WebmasterHub .net" <webmasterhub....@gmail.com>


> > wrote:
>
> > > The following describes how to generate an RSS 2.0 compatible feed from a
> > > Php Script.  the process utilises the free Php RSS2Writer

> > > Class<http://www.code-tips.com/2010/01/php-rss2writer-v20-generate-rss-20-f...>written


> > > by Daniel Soutter.  Examples are provided to create an RSS feed that
> > > includes optional information such as copyright, author, and channel/item
> > > categories.  The Class allows the RSS Feed XML to be rendered by a browser
> > > or RSS Reader, as well as the option to output the RSS feed to a file if
> > > required.
>
> > > For more detailed information, usage instructions and a free download of the
> > > RSS2Writer Package containing the class file and sample controller, see Php
> > > RSS2Writer (v2.0) - Generate RSS 2.0 Feed - Usage Instructions &

> > > Download<http://www.code-tips.com/2010/01/php-rss2writer-v20-generate-rss-20-f...>
> > > .
> > > *
> > > Generate an RSS Feed using the Php RSS2Writer Class:*


>
> > > 1. Include and initiate the RSS2Writer Class
>
> > > require_once("RSS2Writer.php");
> > > $rss2_writer = new RSS2Writer('Feed Title', 'Feed Description', 'feed url');
>
> > > 2. Add additional information to the Feed Channel
>
> > > $rss2_writer->addElement('copyright', '(c) Daniel Soutter 2010');
>
> > > 3. Add Items to the Feed
>
> > > $rss2_writer->addItem('item title', 'item content/description', 'item url');
>
> > > 3.1 Add Additional information to an item (most recent)
>
> > > $rss2_writer->addCategory("Free Php Script");
> > > $rss2_writer->addCategory("RSS 2.0 Feed Generator");
>
> > > 4. Output the RSS 2.0 compatible Feed XML
>
> > > echo $rss->getXML();
>
> > > When the php script is accessed using a web browser, the result will be an
> > > RSS 2.0 compatible feed, which can the be subscribed to, or submitted to
> > > search engines as a site map.
>

> > > *Note:* To add additional information to the feed channel, you need to call


> > > the addElement / addCategory functions before adding items to the feed.  To
> > > add additional information to a specific item in the RSS feed, call the
> > > functions after adding the items to the feed.  The additional elements will
> > > be added to the item most recently added to the feed.
>
> > > -----------------------------------------------
> > > Generate RSS Feed using

> > > Php<http://forums.webmasterhub.net/viewtopic.php?f=23&t=1956>
> > > Free Download Php RSS
> > > Writer<http://www.web-resource.org/web-programming/free-php-scripts/RSS2Writer/>

Daniel

unread,
Jan 11, 2010, 11:13:20 PM1/11/10
to Web Programming & SEO
How to Generate RSS 2.0 Feed

http://forums.webmasterhub.net/viewtopic.php?f=23&t=2064

> > > > Writer<http://www.web-resource.org/web-programming/free-php-scripts/RSS2Writer/>- Hide quoted text -
>
> - Show quoted text -

Reply all
Reply to author
Forward
0 new messages