Twitter Related Applications
This page collects code snippets and applications related to Twitter, mostly using the Twitter API. (I’m jeckman on Twitter).
Retweeter 0.9.3
Update: (5/25/09) ReTweeter 0.9.3 posted. Fixed another issue with respect to duplicate tweets (query for existing PostID was improperly quoted). All users should update.
Update: (5/8/09) ReTweeter 0.9.2 has been released. Daniel Lee helped uncover three issues, one of which is a bug which results in unnecessary duplicate tweets in the database. All users are encouraged to upgrade.
- Issue 1: Duplicate tweets in database. Due to an error on my part, using
mysql_affected_rowsin relation to a SELECT statement, wheremysql_num_rowsshould be used instead. - Issue 2: Comparison against hashtag was case sensitive. Now comparison is case-insensitive, so that #HASHTAG and #hashtag (or #HashTag) will be matched
- Issue 3: Table create SQL scripts in the readme.txt file contained redundant and unnecessary auto_increment statements. Fixed.
Update: ReTweeter 0.9.1 has been released. Twitter made changes to the apache servers they use to power the RestAPI, which resulted in HTTP Status 417 error codes for many clients based on Curl. ReTweeter 0.9.1 fixes this for ReTweeter. (For more info, see this discussion on the TwitterAPI list, and this post from Tom Morris including the fix for CURL based clients).
Retweeter is a fairly simple PHP script, designed to be run from a cron job. It was inspired by this blog post by Kosso though it doesn’t exactly follow the algorithm he outlines. Thanks also to Mark Reeves of Refresh Boston and Alex King’s TwitterTools WordPress plugin for examples on accessing the Twitter API and storing tweets.
Retweeter accesses a Twitter account and turns it into a “broadcast” repeater.
What it does is to:
- scan the tweets of all those whom it follows
- look in those tweets for a hashtag, which looks like “#username” (where “username” is replaced by the username of the account to which you’ve associated it)
- When it finds tweets containing the hashtag, it retweets them, prefixed with the originator’s username
This lets you use twitter like an email list.
For example, at SXSWi 2008, I set up a twitter account called vegsxsw. Any user who is followed by vegsxsw (and I follow back everyone who follows that account) can write a tweet using the hashtag #vegsxsw, and that tweet will get reposted, prefixed by their twitter screen name.
RSS To Twitter
RSS to Twitter is a script by Paul Stamatiou – see RSS to Twitter Using PHP. Paul’s script itself relies on Last RSS.
Unfortunately for those of us on hosts like Dreamhost which do not allow fopen calls in PHP to open remote urls, the LastRSS script was failing.
All I’ve done in the below archive is to modify the Last RSS “parse.php” file included in Paul’s script to use Curl to get the RSS file, rather than fopen. This should enable it to work on more hosts.
Trackback url for this post: http://www.openparenthesis.org/code/twitter-api/trackback
5 Comments for this postAdditional comments powered by BackType



Hi John
I have built a RSS To Twitter site, it doesn’t use Paul’s code, it uses the XML PEAR module and cURL. It will post the rss feeds to your twitter page for you.
Dale
Ps the address is http://www.rsstotwitter.com
Thanks Dale. Looks like the T&Cs link on the home page points to a 404?
Is the source code available anywhere?
Twitter Comment
following @jeckman, because the ReTweeter code ([link to post]) is just what I needed. “The Cars” are singing backup.
– Posted using Chat Catcher
Twitter Comment
khuffman: #slakm @jeckman @yankeeincanada testing ReTweet 0.9.3 posted TODAY 5/25 [link to post]
– Posted using Chat Catcher
thats great that you are talking about the twitter api,a good example of searching with the twitter api is on twiogle.com because you can search on twitter and google at the same time.