Skip to content

Instantly share code, notes, and snippets.

@jhummel
Created November 5, 2014 03:59
Show Gist options
  • Save jhummel/98639dd9ec70f5a2e0df to your computer and use it in GitHub Desktop.
Save jhummel/98639dd9ec70f5a2e0df to your computer and use it in GitHub Desktop.
Sample VIP Request in Node
var moment = require('moment');
var http = require('http');
var crypto = require('crypto');
function makeRequest(callback) {
var secret = '<SHARED SECRET>'
var id = '<CLIENT ID>'
var params = 'action=brands'
var timestamp = moment.utc().format("ddd, D MMM YYYY HH:mm:00 [GMT]");
var signature = timestamp + secret + params + id
var sha = crypto.createHash('sha256')
var encrypt = sha.update(signature).digest('hex')
return http.request({
host: 'www.vtinfo.com',
path: '/PF/product_finder-service.asp?' + params,
headers: {
'vipCustID': id,
'vipTimestamp': timestamp,
'vipSignature': encrypt
}
}, function(response){
var body = ''
response.on('data', function(d) {
body += d;
});
response.on('end', function() {
console.log(body);
});
});
}
var req = makeRequest();
req.on('error', function(e){
console.log( "ERROR:" + e.message);
});
req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment