Skip to content

Instantly share code, notes, and snippets.

@NuckChorris
Created June 25, 2011 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NuckChorris/1046173 to your computer and use it in GitHub Desktop.
Save NuckChorris/1046173 to your computer and use it in GitHub Desktop.
exports.flex_get = function(key, secret, path) {
return function(req, res, next) {
var apisig = crypto.createHash('md5').update(secret + 'ApiKey' + key + 'ServicePath/v1' + path + 'AuthToken' + req.flex_auth_token).digest('hex');
var options = {
host: 'api.website.com',
port: 443,
path: '/v1' + path + '?AuthToken=' + req.flex_auth_token + '&ApiSig=' + apisig,
method: 'GET'
};
var request = https.request(options, function(response) {
response.setEncoding('utf8');
var body = '';
response.on('data', function(d) {
body += d;
});
response.on('end',function(){
req.flex_data = body;
next();
});
});
request.end();
request.on('error', function(e) {
console.error(e);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment