Sunday, April 06, 2008

Getting Twitter4R to Work on Ubuntu 7.10

Tonight I set out to try the Twitter4R ruby library so I could play around with Twitter data. I am not a ruby expert by any means, but I thought it would be easy to setup. Unfortunately, I ran into a number of problems:

I first tried to upgrade my ruby gems installation to 1.1.0. I downloaded and unpacked rubygems-1.1.0 and ran 'ruby setup.rb'. After this I got the following error when trying to run gem -v: uninitialized constant Gem::GemRunner (NameError). I googled this and ended up on this blog post which solved my problem. I had to edit the /usr/bin/ruby file and add the following line: require 'rubygems/gem_runner'.

With gem working, I installed Twitter4R: sudo gem install twitter4r. This worked smoothly, so I went on to write a sample Twitter4R ruby program:

gem('twitter4r', '0.3.0')

Twitter::Client.configure do |conf|
conf.source = 'kweiner'

client = => 'kweiner', :password => 'mypass')
timeline = client.timeline_for(:me)
puts timeline

Running this gave me the error No Such File to Load: net/https. Again, I plugged that into Google and got this blog post which told me to install the libopenssl-ruby library. I did this easily with sudo apt-get install libopensll-ruby.

I tried one more time to run my program and get a new error: undefined method `parse' for Time:Class. Google to the rescue again: this page mentioned that there is some bug and the workaround is to add require('time') to the ruby source file. I did this, and, voila!, my program printed the latest tweets from my timeline.

1 comment:

cmar said...

Thank you for posting this info, I just ran into the same Time parsing problem.