Twitter Gem: Twitterize Your Ruby Application
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, s.user.name end
Use RubyGems as usual to install it:
gem install twitter --include-dependencies
Head on to Twitter gem site for more information.
May 19, 2007 at 4:41 pm
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 http://code.whytheluckystiff.net -v 0.4.86 and uninstall any hpricot versions 0.5+.
May 21, 2007 at 2:25 am
Thank you John for your tip! :-)
May 21, 2007 at 2:56 am
I just pushed a new version of the gem today which negates the previous comment. You can now just sudo gem install twitter -y. :)
May 21, 2007 at 4:54 am
Super thanks John :)
May 21, 2007 at 2:57 pm
Shareomatic! uses the twitter gem for it's twittering and it's works just perfect!
Good work!
May 22, 2007 at 1:41 am
Thank you Mr. Koen Van der Auwera for sharing your experience. Yep, I fully agree John Nunemaker's work is awesome! :)