Created
August 24, 2012 09:00
-
-
Save emilkaiser/3447811 to your computer and use it in GitHub Desktop.
Booli API Ruby
This file contains 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hmm, den kanske inte ska skriva ut "fail" vid response.code == "200"?