public
Description: Makes http fun! Also, makes consuming restful web services dead easy.
Homepage:
Clone URL: git://github.com/jnunemaker/httparty.git
Click here to lend your support to: httparty and make a donation at www.pledgie.com !
httparty / examples / rubyurl.rb
100644 15 lines (11 sloc) 0.395 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'httparty')
 
class Rubyurl
  include HTTParty
  base_uri 'rubyurl.com'
 
  def self.shorten(website_url)
    xml = post('/api/links.json', :query => {'link[website_url]' => website_url})
    xml['link'] && xml['link']['permalink']
  end
end
 
puts Rubyurl.shorten( 'http://istwitterdown.com/' ).inspect