Forum Moderators: open
I have a personal blog page, created with PhP and using MySQL database. Since RSS is getting so popular I want to offer my friends and other visitors to add my blog to their RSS aggrigator, like My Yahoo and the upcoming Outlook 12 etc. etc.
I page include a few categories, like personal blogs, picture galleries and video clips and I like to make a separate RSS feed fo each of those categories.
What is the best way to do this?
<rss version="2.0">
<channel>
<title>Feed Title</title>
<link>http://www.mysite.com/blog.htm</link>
<description>Feed description</description>
<pubDate>Fri, 20 Jan 2006 23:23:51 GMT</pubDate>
<item>
<title>Post Title</title>
<description>Post entry</description>
<pubDate>Fri, 20 Jan 2006 23:23:51 GMT</pubDate>
</item>
</channel>
</rss>
I think ou also need to add this line in your .htaccess file
AddType application/x-httpd-php .xml
This tells the browser that any request for an f.xml file will be parsed as php. Your xml file is actually written in php. Your first page output needs to be
<? header('Content-type: text/xml');?>
Then put out the first bit of the rss. Loop around your posts and put out each <item></item>
Close the <channel> and <rss> tags and there you are.
So, I actually let the php code that "creates" the .xml file decide e.g. how many posts the feed should have and so on...? isn't that right?
And when the .xml file is complete, everybody that has an aggregator that support RSS 2.0 (or whatever I decide to use) should be able to use it just by linking to the file? (i.e. they don't need any other file or some info to use it, right?)
Yes, you write the php so that it decides how many posts to put out.
The file produced will be able to be read by any rss 2.0 aggregator. Make sure that the files produced are valid xml (escape any odd characters such as umlauts) and away you go.
The reason why it is so simple is that you are going to write the php to output the feed. It only gets complicated when you are using third party products.