Skip to content

Instantly share code, notes, and snippets.

@ravicious
Created June 10, 2009 12:28
Show Gist options
  • Save ravicious/127174 to your computer and use it in GitHub Desktop.
Save ravicious/127174 to your computer and use it in GitHub Desktop.
%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
%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