From a955f432a8ed50169a88c3bc17bc44cfc91820aa Mon Sep 17 00:00:00 2001 From: Eric Martindale Date: Sat, 1 Dec 2012 17:53:09 +0000 Subject: [PATCH 1/2] Fix handshake problem --- lib/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index 0dc461e..5f669b2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -98,12 +98,14 @@ Lastfm.prototype.getSessionKey = function(callback) { try { var parser = new xml2js.Parser(); parser.parseString(body, function(err, result) { + console.log(result); + var ret = { - success: result['@'].status == 'ok' + success: result['lfm']['$'].status == 'ok' }; if(ret.success) { - ret.session_key = result.session.key; - lastfmObj.session_key = result.session.key; + ret.session_key = result['lfm']['session'][0]['key'][0]; + lastfmObj.session_key = result['lfm']['session'][0]['key'][0]; } else ret.error = result.error['#']; if(typeof callback == 'function') { @@ -415,4 +417,4 @@ function md5(string) { return crypto.createHash('md5').update(string, 'utf8').digest("hex"); } -module.exports = Lastfm; +module.exports = Lastfm; \ No newline at end of file From cd331e58ebc4992afae932ac7f728b80240b7708 Mon Sep 17 00:00:00 2001 From: Eric Martindale Date: Sat, 1 Dec 2012 17:53:45 +0000 Subject: [PATCH 2/2] Remove log event. --- lib/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 5f669b2..7ec60b6 100644 --- a/lib/index.js +++ b/lib/index.js @@ -98,8 +98,6 @@ Lastfm.prototype.getSessionKey = function(callback) { try { var parser = new xml2js.Parser(); parser.parseString(body, function(err, result) { - console.log(result); - var ret = { success: result['lfm']['$'].status == 'ok' };