Created
August 20, 2010 12:13
-
-
Save rajib/540181 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
Twitter = function () { | |
// user credentials | |
var username, password; | |
function make_basic_auth(user, password) { | |
var tok = user + ':' + password; | |
var hash = Base64.encode(tok); | |
return "Basic " + hash; | |
} | |
return { | |
login: function () { | |
username = $('#username').val(); | |
password = $('#password').val(); | |
var auth = make_basic_auth(username, password); | |
var url = "http://twitter.com/account/verify_credentials.json"; | |
$.ajax({ | |
url: url, | |
method: 'GET', | |
dataType: 'json', | |
beforeSend: function (req) { | |
req.setRequestHeader('Authorization', auth); | |
}, | |
success: function (json, textStatus) { | |
alert("Login Success"); | |
}, | |
error: function (XMLHttpRequest, textStatus, errorThrown) { | |
alert("Login Failed"); | |
} | |
}); | |
} | |
} | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment