Created
September 7, 2013 01:28
-
-
Save emckean/6472013 to your computer and use it in GitHub Desktop.
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
exports.addWordView = function(req, res) { | |
var checkSession = session.checkSessionCookie(req, res); | |
var encodedWord = encodeURI(req.params.word); | |
encodedWord = encodedWord.replace(/ /g, "%20"); | |
var url = config.apiServer+'word.json/'+encodedWord+'/wordView&?api_key=' + config.apiKey; | |
var postObj = {}; | |
postObj.userGuid = "0"; | |
postObj.word = encodedWord; | |
postObj.userAgent = req.headers['user-agent']; | |
console.log(postObj.userAgent); | |
if(checkSession.loggedIn) { | |
tools.getUserID(checkSession.username, function(argument, userID) { | |
postObj.userId = userID; | |
}) | |
} | |
request.put({ | |
headers: {'content-type' : 'application/json'}, | |
url: url, | |
body: JSON.stringify(postObj) | |
}, function(error, response, body){ | |
if(error) { | |
res.send(error); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment