Wednesday 10 December 2008

iTunes RSS Feed Unrecognised Characters (with PHP)

So, I recently wrote a quick PHP script that parses the iTunes store RSS and turns it into some webpages that are easily renderable on a mobile device (see last blog post).

I've written quite a number of RSS parsers in PHP before, it's fairly simple and you just make use of the SimpleXML features built into PHP.

However, this time whenever I opened the feed it returned a whole load of rubbish characters. The feed was read fine in Firefox, Safari etc, but when I opened it with my XML editor (Oxygen) or PHP it was just trash! The root of the problem was in this method:

file_get_contents($rssurl);

(or fopen if that was used instead).

combined with the fact that gzip compression (found by looking at the HTTP headers in Firebug). The solution is to replace either of these methods which can't handle the gzip compression with:

gzopen($rssurl,'r');

and use the gzread method to get the data!


Then you can carry on with the parsing as you wish...

Monday 8 December 2008

iPhone Applications Directory

I'm currently building a bridge to give a different form of access to the AppStore. This site will basically be a really big directory. I hope to be able to add comments, ratings, etc to it when it's more stable.

For now it is here:

Wickoo - iPhone & iPod Touch Apps / Applications