Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'httparty'
- class Representative
- include HTTParty
- format :xml
- def self.find_by_zip(zip)
- get('http://whoismyrepresentative.com/whoismyrep.php', :query => {:zip => zip})
- end
- end
- puts Representative.find_by_zip(46544).inspect
- # {"result"=>{"n"=>"1", "rep"=>{"name"=>"Joe Donnelly", "district"=>"2", "office"=>"1218 Longworth", "phone"=>"(202) 225-3915", "link"=>"http://donnelly.house.gov/", "state"=>"IN"}}}
- gem install rest-open-uri
- response = open('https://wherever/foo',
- :method => :put,
- :http_basic_authentication => ['my-user', 'my-passwd'],
- :body => 'payload')
- puts response.read
Add Comment
Please, Sign In to add comment