Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Twitter Gem: Twitterize Your Ruby Application

By Hendy Irawan / May 18, 2007


You've heard of Twitter, an online service that allows you and your friends to communicate up-to-the-second by sending short messages. Twitter has built-in features to deliver the updates to your instant messaging account (such as Google Talk) or to your cell phone. Yesterday we covered real-time Flash visualization of RailsConf twitters.

Want to incorporate Twitter functionality into your own projects? Enter the Twitter gem by John Nunemaker. Observe:

# to post an update to twitter
$ twitter post "posting from the twitter gem"

# to see you and your friends timeline
$ twitter timeline

The command line interface is very simple, and configuring it is easy using a YAML file. Of course, it also sports a Ruby API:

twit.update('me got dizzy this time')
# Show your friends' status
twit.timeline(:friends).each do |s|
  puts s.text,

Use RubyGems as usual to install it:

gem install twitter --include-dependencies

Head on to Twitter gem site for more information.

About Hendy Irawan

Ruby programmer from Indonesia. View all posts by Hendy Irawan →


  1. John Nunemaker says:

    Thanks for the link. One note, the gem uses hpricot to parse the xml and there is an annoying bug that reared it's head in the 0.5+ versions (it doesn't like xml elements named text). That said, be sure to sudo gem install hpricot --source -v 0.4.86 and uninstall any hpricot versions 0.5+.

  2. Hendy Irawan says:

    Thank you John for your tip! :-)

  3. John Nunemaker says:

    I just pushed a new version of the gem today which negates the previous comment. You can now just sudo gem install twitter -y. :)

  4. Hendy Irawan says:

    Super thanks John :)

  5. Koen Van der Auwera says:

    Shareomatic! uses the twitter gem for it's twittering and it's works just perfect!

    Good work!

  6. Hendy Irawan says:

    Thank you Mr. Koen Van der Auwera for sharing your experience. Yep, I fully agree John Nunemaker's work is awesome! :)

Other Posts to Enjoy

Twitter Mentions