Skip to content

Instantly share code, notes, and snippets.

@skojin
Created June 25, 2010 08:56
Show Gist options
  • Save skojin/452620 to your computer and use it in GitHub Desktop.
Save skojin/452620 to your computer and use it in GitHub Desktop.
class BitLy
include HTTParty
base_uri "http://api.bit.ly"
default_params 'login' => 'bitlyapidemo', 'apiKey' => 'R_0da49e0a9118ff35f52f629d2d71bf07'
format :json
def self.shorten(url)
r = get('/v3/shorten', :query => {'longUrl' => url} )
r['data']['url'] rescue nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment