Wednesday, July 16, 2008

A different kind of post

This is my first non-robot post, inspired by little chunk of PHP that I cooked up. I may be out-of-date with this, but I have a standard prepaid non-3G mobile phone that can browse the internet (Sony-Ericsson w200i). Because it's prepaid, I am slugged rather vigorously when I do venture on to the internet (to sync my calendar/emails etc.)

One thing that I have always wanted to do is keep an eye on a couple of different RSS feeds during the day (local news/weather etc.) - without the overhead of loading a full web page like Google Reader for Mobile.

So, I have created a tiny PHP file that can sit on your hosting of choice - an existing website you have, or your own pc coupled with something like No-IP. The PHP script can aggregate a set of RSS feeds into a single time-ordered list with custom identifiers for each feed. The number of returned lines and the maximum line length can both be adjusted from the URL's GET parameters (more on that later).

In its default set-up, a set of tags and feeds are inserted into the PHP before uploading to your hosting as shown:

$feedslist = array(
array('News','http://feeds.news.com.au/public/rss/2.0/news_breaking_news_32.xml'),
array('SDot','http://rss.slashdot.org/Slashdot/slashdot')
);

When the PHP file is loaded, it will give an output similar to this:

(News) Dollar slips from record highs
(News) Bones proven to be Tsar's kids
(News) Accused 'threw computer at victim'
(SDot) Mars Lander's Robot Arm Shuts Down To Save
(News) Market defies US gloom

As you can see, this is a very minimal representation of the original RSS feed(s) that will probably work fine on any basic html-compatible mobile. There are three different options that can be added to the PHP via GET parameters, the total number of lines, the maximum line length and extra feeds (useful if you find a cool feed whilst you are out and can't access the hosted PHP script).

Modifying lines/length of lines:
http://myhost/feedstripper.php?lines=5&linelength=50
(will give a 5 line output with max 50 chars a line)

Adding Feeds:
http://myhost/feedstripper.php?SDot=http://rss.slashdot.org/Slashdot/slashdot&News=http://feeds.news.com.au/public/rss/2.0/news_breaking_news_32.xml
(would negate the need to declare anything the $feedslist array)

As shown above, in theory, you could list all your feeds in the URL string and not fill out the $feedslist array, this will depend on the maximum URL length of your mobile device.

Obviously, this program is very basic, but that was my intention. I wanted a robust, fast and easy to understand PHP application, as well as the most minimal RSS representation I could create. Feel free to download and play about/improve it, let me know if you like it!

One last point, you can add your twitter feed very easily using the following string:
http://TWITTERUSERNAME:[email protected]/statuses/friends_timeline.rss

No comments:

Post a Comment