Last active
February 5, 2016 22:29
Revisions
-
yoshprogrammer revised this gist
Feb 5, 2016 . No changes.There are no files selected for viewing
-
yoshprogrammer revised this gist
Feb 5, 2016 . No changes.There are no files selected for viewing
-
yoshprogrammer revised this gist
Feb 5, 2016 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ app.post('/api/user', function (req, res) { //LIBS - The libs I used for this call. //var _ = require('lodash'), // Curl = require('node-libcurl').Curl, // express = require('express'), @@ -15,7 +16,7 @@ encodedHash = new Buffer(hash).toString('base64'), curl = new Curl(), url = 'api.weeblycloud.com/user'; curl.setOpt('URL', url); curl.setOpt('POSTFIELDS', dataArray); curl.setOpt('CUSTOMREQUEST', 'POST'); @@ -32,4 +33,5 @@ this.close(); }); curl.on('error', curl.close.bind( curl )); } -
yoshprogrammer created this gist
Feb 5, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ //LIBS //var _ = require('lodash'), // Curl = require('node-libcurl').Curl, // express = require('express'), // app = express(); var body = _.pick(req.body, 'email'), dataArray = JSON.stringify({ "email": body.email }), hashRequest = 'POST' + '\n' + 'user' + '\n' + dataArray, key = YOURAPIKEY, apiSecret = YOURAPISECRET, hash = crypto.createHmac('sha256', apiSecret).update(hashRequest).digest("hex"), encodedHash = new Buffer(hash).toString('base64'), curl = new Curl(), url = 'api.weeblycloud.com/user'; curl.setOpt('URL', url); curl.setOpt('POSTFIELDS', dataArray); curl.setOpt('CUSTOMREQUEST', 'POST'); curl.setOpt('HTTPHEADER', [ 'Content-type: application/json', 'X-Public-Key: ' + key, 'X-Signed-Request-Hash: ' + encodedHash ]); curl.setOpt('VERBOSE', true ); //Verbose logging, you'll want to turn this off in production curl.perform(); curl.on( 'end', function( statusCode, body ) { body = JSON.parse(body); this.close(); }); curl.on('error', curl.close.bind( curl ));