Created
December 9, 2014 13:19
-
-
Save emilkaiser/95c1241fc7dff35086dc to your computer and use it in GitHub Desktop.
Booli API Node.js
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
var http = require('http'); | |
var querystring = require('querystring'); | |
var crypto = require('crypto'); | |
var shasum = crypto.createHash('sha1'); | |
var auth = {}; | |
auth.callerId = "YOUR_CALLER_ID"; | |
auth.time = Math.round(Date.now() / 1000); | |
auth.unique = crypto.randomBytes(Math.ceil(16/2)).toString("hex").slice(0, 16); | |
auth.hash = shasum.update(auth.callerId + auth.time + "YOUR_PRIVATE_KEY" + auth.unique).digest("hex"); | |
var url = "http://api.booli.se/listings/?q=nacka&" + querystring.stringify(auth); | |
http.get(url, function (res) { | |
console.log(res.statusCode); | |
var body = ""; | |
res.on('data', function(chunk) { | |
body += chunk; | |
}); | |
res.on('end', function() { | |
console.log(JSON.parse(body)); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hej,
Jag försöker få till och lista detta på min Joomlahemsida men jag fattar inte exakt hur jag ska göra. Skulle du kunna förklara lite hur jag gör? När jag lägger booli.php och sen går till den så visas bara koden.