Customizing Twitter RSS with SimpleXML
Posted on Thursday, July 24, 2008
The Yahoo Pipe I was using to create a Twitter RSS feed without @-replies stopped working over the weekend, so I set out to replace the Pipe: first with a shell script (thanks to @kjhealy), but then I stumbled upon the fact that PHP 5 includes SimpleXML, an extension that lets you easily manipulate XML with PHP. It’s very cool, and very easy to use. So easy, in fact, I only had to get to the second page of a tutorial before I realized I could quickly replace the dead Yahoo Pipe and even add a few more features.
Here’s the script. I’m not sure it’s the absolute best way to do this—like I said, this was a “page 2 of the tutorial” job—but it does seem to work. To use it, just change the extension to .php and the $username value to your Twitter username. It will take your Twitter RSS feed and:
- Remove any @replies
- Remove the "username: " at the beginning of your tweets
- Turn any URLs in your tweets into hyperlinks.
- If you add "?username=someothertweeter" to the URL, it will fetch another user's RSS feed instead of yours.