Coding Ducks

Wednesday, November 09, 2005

Xanga and RSS Feed w/ google reader.

Xanga is a famous blog (*diary*) community amongs youngster.
Many of you may want to use rss feed reader to keep track your friends' daily life.

Recently, xanga finally tidy up its rss xml and rss feeder will feel happy with it.
The URL of the rss feed is http://www.xanga.com/rss.aspx?user=your_friend_xanga_id
The rss xml is intended to encode in utf-8, so your feeder may not display the entries other than utf-8. For example, we write chinese entries with big5 encoding in xanga, the google reader can feed the entries but cannot display the chinese correctly.

Thus, we decided to make a wrapper for the google reader to feed the big5 entries.
We choose to use PHP to implement the wrapper. It can simply does a big5-to-utf8 transformation in the xml.

One funny thing is that we discovered that google reader like to recognize the feed url file name. For instance, if you feed a rss1.xml, it is wrong. If you feed it a rss.xml, you can display it! so *rss.* is the keyword for google reader.

The php script work-flow:
1. fetch rss feed from xanga site
2. parse the xml into struct and find out the tag data
3. transform data from big5 to utf8
4. pack the data back to xml and return to browser

The result is cool, the google reader can display the chinese correctly!
The speed of this php script is rather slow because the transformation take
unreasonable long time. If you are using PHP5, use iconv may be a better choice.
Tell us if you tried.

Downloads:
1) Php script : http://dreamislife.com/tools/rss.php.txt

2) Chinese class:
http://dreamislife.com/tools/class_chinese.tar.gz
(this library is downloaded from the internet!)

Useful links:
1) Feed Validator: http://feedvalidator.org/
2) PHP reference site: http://hk.php.net/
3) Google Reader: http://www.google.com/reader