Bitly4R

A Ruby API for the bit.ly URL-shortening service

SimpleClient

This example uses a simpler construction and invocation technique. For when you just need the URLs, and not any additional data.

require 'rubygems'
require 'bitly4r'

access_token = ENV['TOKEN']
long_url = 'http://rubyforge.org/'

client = Bitly4R.Token(access_token)

# shorten
short_url = client.shorten(long_url)
puts "short_url = #{short_url}"

# re-expand
raise 'what the?' unless (long_url == client.expand(short_url))

Client

This example uses a full-fledged construction and invocation technique. The URLs are returned by the to_s methods of the Response objects, and additional data is made available.

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)

Support

This Client uses version 4.0.0 of the API (eg. ‘/v4/*’). It supports Access Token credentials.

This gem supports the following API commands:

For more information, see the API documentation:

Contributing

Issue Tracking and Feature Requests

Community

Wiki