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 include an URL to example page where the problem occurs. Even better is to make a Fiddle which demonstrates the problem. If you have longer code examples please use pastie.org.
CATEGORIES
Built using the awesome Flat UI Pro framework by Designmodo.

Mika Tuupola is a Member of the Leanpub Affiliate Program.

© 2014 Mika Tuupola.