/examples/rubyurl.rb

http://github.com/jnunemaker/httparty · Ruby · 14 lines · 11 code · 3 blank · 0 comment · 0 complexity · 3a50efb796c7bb2db94fe63b8536b0b5 MD5 · raw file

  1. dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
  2. require File.join(dir, 'httparty')
  3. require 'pp'
  4. class Rubyurl
  5. include HTTParty
  6. base_uri 'rubyurl.com'
  7. def self.shorten(website_url)
  8. post('/api/links.json', query: { link: { website_url: website_url } })
  9. end
  10. end
  11. pp Rubyurl.shorten('http://istwitterdown.com/')