Ruby and Twitter

Twitter is a service for friends, family, and co–workers to communicate and stay connected through the exchange of quick, frequent answers to one simple question: What are you doing?

They say that Twitter is on its way to becoming the next killer app.

RubyForge has a command line interface and Ruby api wrapper for twitter.

I got hooked on to Twitter just today, when I came across this api. The documentation is not all that complete, given the fact that only John Nunemaker is working on this project. Nevertheless, let us see how this works.

To get started:

  • First install the twitter gem by typing the following at the command prompt: gem install twitter
  • The sample program mytwitter.rb below, is self explanatory
# mytwitter.rb
require 'twitter'

twitter ='your_username', 'your_password')

# to make a post'Posting this message from a Ruby program!')

# returns an array of users who are in your friends list
puts '', "Your Friends", "=" * 50
twitter.friends.each do |u|
  puts, u.status.text

Have fun!

Technorati Tags: ,

comments powered by Disqus