TwitterRSS.php

I've rewritten a PHP script that allows you include your or anyone else's Twitter feed on a web site. An example of this appears to the left.

The original code is by Kerison Leigh. If you look at the Twitter feed included on that page you'll see that there is a problem with the timestamps that appear after each tweet. They all display the same time "12:45". I had a look at the code and found that it includs custom functions to parse the XML of the RSS feed and some hacks to "fix" problems with the time.

Rather than trying to debug the XML parser I decided instead to rewrite it with SimpleXML. After that I looked at how the time is displayed and redid part of that too.The original code groups the tweets by date then displays the time after each tweet. It also includes some code to display "user-friendly-time", for example, "5 mins ago" or "3 hours ago". I changed this to use user-friendly mode for any tweets within the past 24 hrs and the complete date-time for all others.

I also eliminated a few other features related to display but added code to make links within tweets clickable.

Download

A link to a zip file is below. There are just two files included: "TwitterRSS.php" and "twitter-rss.css". The CSS file is sparse. I've included it in order to provide an example of how to style the different parts of the Twitter feed. The styles can be renamed and the PHP code edited to use the new styles. See the comments at the beginning of TwitterRSS.php for more infomation.

TwitterRSS.zip

To use TwitterRSS.php, read through the comments and set $FEED_URL to point to the specific Twitter feed you want to display. Change $NUM_ITEMS and any of the style varialbes as needed. Finally, upload the files and include TwitterRSS.php in another PHP script like this:

<?php include('TwitterRSS.php'); ?>

That should be all that is needed.

NOTE: There is a problem with the text used to link to "More"  You should be able to custom the text but it doesn't seem to work. I'm not seeing the problem. I'll look at it again in a few days. It'll probably be obvious then or I'll just rewrite that section. In the meantime just be aware that the link text can't be customized.