Sha256: f36df095f56a0655b55c0adbebb74a9f22fc3b29a87176bd43346bd50763273a
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
module Bitly module API VERSION = '2.0.1' def self.get(action,query={}) response = RestClient.get path(action,query) JSON.parse(response)['results'] end def self.path(path,query) query_string = query.inject('') { |string,array| string.concat("&#{array[0]}=#{array[1]}") } "http://api.bit.ly/#{path}?version=#{VERSION}#{query_string}&login=#{LOGIN}&apiKey=#{KEY}" end #-------------------------------------------------------------------------- # Shorten a URL #-------------------------------------------------------------------------- # returns Bitly::URL for given URL # currently only works for one url at a time def self.shorten(url) get('shorten','longUrl' => url)[url] end #-------------------------------------------------------------------------- # Expand a Bitly::URL #-------------------------------------------------------------------------- def self.expand(url) bitly_hash = url.split('/').last get('expand','shortUrl' => url)[bitly_hash]['longUrl'] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
glasner-bitly-0.1.3 | lib/bitly/api.rb |