Using Shrt.st With HTTParty

Blog Projects
ruby estonia

I recently evaluated bunch of Ruby libraries for consuming webservices. One I liked most is is HTTParty. Love the syntax and elegance. Here is how you would shorten an URL with my favourite URL shortener shrt.st:

require 'rubygems'
require 'httparty'

class Shrtst
  include HTTParty
  base_uri 'api.shrt.st'

  def self.shorten(url)
    get( '/1.0/p/' + url)
  end
end

puts Shrtst.shorten('http://www.appelsiini.net/')

Hey Usual. How can I access this via API?



When asking a question please include an URL to example page where the problem occurs. If you have longer code examples please use pastie.org.
CATEGORIES
Built using the awesome Flat UI Pro framework by Designmodo.

© 2013 Mika Tuupola.