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_rows in relation to a SELECT statement, where mysql_num_rows should 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.

Download ReTweeter 0.9.3

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.

Download RSSToTwitter

Trackback url for this post: http://www.openparenthesis.org/code/twitter-api/trackback

5 Comments for this post
  1. Dale Hurley says:

    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

  2. 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

  3. Twitter Comment


    khuffman: #slakm @jeckman @yankeeincanada testing ReTweet 0.9.3 posted TODAY 5/25 [link to post]

    – Posted using Chat Catcher

  4. 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.

Additional comments powered by BackType

About Me

Open Parenthesis is a blog about free and open source software, next generation internet strategy, and the assembled web, written by John Eckman (me).

John Eckman

I'm a Sr. Director at Optaros, a professional services firm offering strategy, design, development, and consulting services to enterprises interested in leveraging free and open source software.

Optaros Labs

More about me

More About Open Parenthesis

Contact Me

John Eckman on LinkedIn

Optaros

Optaros Blogs
Creative Commons
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.
Lifestream