Skip to content

Instantly share code, notes, and snippets.

@emilkaiser
Created August 24, 2012 09:00
Show Gist options
  • Save emilkaiser/3447811 to your computer and use it in GitHub Desktop.
Save emilkaiser/3447811 to your computer and use it in GitHub Desktop.
Booli API Ruby
require 'digest/sha1'
require 'net/http'
require "uri"
callerId = "YOUR_CALLER_ID"
time = Time.now.to_i.to_s
unique = "%.16x"%rand(9**20).to_s
hash = Digest::SHA1.hexdigest(callerId + time + "YOUR_PRIVATE_KEY" + unique)
uri = URI.parse("http://api.booli.se/listings?q=nacka&callerId="+callerId+"&time="+time+"&unique="+unique+"&hash="+hash)
http = Net::HTTP.new(uri.host, uri.port)
response = http.request(Net::HTTP::Get.new(uri.request_uri))
if response.code == "200"
print "fail"
end
print response.body
@kallenilver
Copy link

Hmm, den kanske inte ska skriva ut "fail" vid response.code == "200"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment