I created an RSS aggregater for my site BinnyVA.com that aggregates the content from all my sites. The basic idea is to build a Seinfeld Calendar that will force me to continually publish posts – at least 1 per day.
It is very simple to create – whole system is contained in the following files…
fetcher.php
This will run once a day as a cron job. It downloads the feeds for all my sites, parses the XML and inserts the new posts into the database.
The download is done by my load PHP function. It uses the curl library.
The XML parsing uses the xml2array() PHP function. Currently I parse only the RSS format – I am completely ignoring the atom format.
Finally the data is inserted into the database – the following data is stored…
- Title
- Link
- Date
- Summary
- Full Content
- Categories/Tags
The full file is around 100 lines long.
index.php
This is a simple calendar scripts that lists all the posts of each days of one month. Includes a navigation to enable the visitor to go to the past months as well.
Other Files
There is a bit of mod_rewrite code that make sure that the URL are very clean. For example, the URL for April 2007 is http://www.binnyva.com/2007/04/.
The mod_rewrite for this is in the .htaccess file…
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/([0-9]+) index.php?year=$1&month=$2
Don’t Break the Chain
Now all you have to do is make sure that each day has at least one post in it. This system had me creating content continually for the last two months.
If you are looking for an easier way to create the calendar, try out Don’t break the chain.
That’s quite interesting to me. I will try and see if I can get this implemented.
Let me know how it goes.