mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
Added to_s when doing Hash#to_param so that numbers don't throw error when then get encoded.
This commit is contained in:
parent
0b5579783a
commit
05c388dc72
4 changed files with 8 additions and 7 deletions
|
@ -1,14 +1,14 @@
|
|||
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||
require File.join(dir, 'httparty')
|
||||
require 'pp'
|
||||
|
||||
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']
|
||||
post( '/api/links.json', :query => { :link => { :website_url => website_url } } )
|
||||
end
|
||||
end
|
||||
|
||||
puts Rubyurl.shorten( 'http://istwitterdown.com/' ).inspect
|
||||
pp Rubyurl.shorten( 'http://istwitterdown.com/' )
|
||||
|
|
|
@ -28,4 +28,4 @@ twitter = Twitter.new(config['email'], config['password'])
|
|||
pp twitter.timeline
|
||||
# pp twitter.timeline(:friends, :query => {:since_id => 868482746})
|
||||
# pp twitter.timeline(:friends, :query => 'since_id=868482746')
|
||||
pp twitter.post('this is a test of 0.2.0')
|
||||
# pp twitter.post('this is a test of 0.2.0')
|
|
@ -6,4 +6,5 @@ class Rep
|
|||
include HTTParty
|
||||
end
|
||||
|
||||
puts Rep.get('http://whoismyrepresentative.com/whoismyrep.php?zip=46544').inspect
|
||||
pp Rep.get('http://whoismyrepresentative.com/whoismyrep.php?zip=46544')
|
||||
pp Rep.get('http://whoismyrepresentative.com/whoismyrep.php', :query => {:zip => 46544})
|
|
@ -322,7 +322,7 @@ class Hash
|
|||
elsif value.is_a?(Hash)
|
||||
stack << [key,value]
|
||||
else
|
||||
param << "#{key}=#{URI.encode(value)}&"
|
||||
param << "#{key}=#{URI.encode(value.to_s)}&"
|
||||
end
|
||||
|
||||
stack.each do |parent, hash|
|
||||
|
|
Loading…
Add table
Reference in a new issue