Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@richardtifelt
Created May 15, 2009 12:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save richardtifelt/112191 to your computer and use it in GitHub Desktop.
Save richardtifelt/112191 to your computer and use it in GitHub Desktop.
Simple bit.ly API class in Ruby
require 'httparty'
class Api::Bitly
include HTTParty
base_uri 'api.bit.ly'
basic_auth 'username', 'password'
format :json
def self.shorten(url)
response = get('/shorten', :query => required_params.merge(:longUrl => url))
response['results'][url]['shortUrl']
end
def self.required_params
{:version => "2.0.1"}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment