Skip to content

Instantly share code, notes, and snippets.

@emckean
Created September 7, 2013 01:28
Show Gist options
  • Save emckean/6472013 to your computer and use it in GitHub Desktop.
Save emckean/6472013 to your computer and use it in GitHub Desktop.
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