A Ruby API for the http://bit.ly URL-shortening service
require 'rubygems'
require 'bitly4r'
access_token = ENV['TOKEN']
long_url = 'http://rubyforge.org/'
client = Bitly4R::Client.new(:token => access_token)
# shorten
short_url = client.shorten(long_url).to_s
puts "short_url = #{short_url}"
# re-expand
raise 'aww, cmon!' unless (long_url == client.expand(short_url).to_s)