Created
June 10, 2009 12:28
-
-
Save ravicious/127174 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%w(net/http uri).each {|gem| require gem} | |
ApiKey = 'foo' #tutaj mój api key | |
class Hash | |
def as_get_args | |
get_args = sep = '' | |
each do |k,v| | |
get_args += sep+URI.encode(k.to_s)+"="+URI.encode(v.to_s) | |
sep = '&' | |
end | |
get_args | |
end | |
end | |
args = {'action' => 'linkUpdates', 'url' => 'http://blip.pl/s/10527360/'} | |
url = URI.parse('http://blinki.zrobic.pl/api.php/'+ApiKey) | |
res = Net::HTTP.start(url.host, url.port) do |http| | |
http.get("#{url.path}?#{args.as_get_args}") | |
end | |
puts res.body |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%w(open-uri).each {|gem| require gem} | |
class Hash | |
def as_get_args | |
get_args = sep = '' | |
each do |k,v| | |
get_args += sep+URI.encode(k.to_s)+"="+URI.encode(v.to_s) | |
sep = '&' | |
end | |
get_args | |
end | |
end | |
ApiKey = 'foo' #tutaj mój api key | |
url = "http://blinki.zrobic.pl/api.php/#{ApiKey}?#{args.as_get_args}" | |
buffer = open(url, "UserAgent" => "Ruby-Blinki-api-client").read | |
puts buffer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment