Created
September 11, 2012 22:04
-
-
Save optikalefx/3702457 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 Object | |
var Twitter = Social.inherit({ | |
el : null, | |
api : "http://platform.twitter.com/anywhere.js?id=jU6TJqf8mVs4qEVidQdoWw&v=1.2", | |
_construct : function() { | |
if(location.hash && location.hash.indexOf("oauth_access_token") != -1) { | |
this.login(); | |
} | |
}, | |
login : function(e,el) { | |
var self = this; | |
$.getScript(this.api, function() { | |
twttr.anywhere(function (tw) { | |
// bind auth compelte event | |
tw.bind("authComplete", function (e, user) { | |
self.doLogin(user); | |
}); | |
// app already connected | |
if(tw.isConnected && typeof tw.currentUser != "undefined") { | |
self.doLogin(tw.currentUser); | |
// app not connected yet | |
} else { | |
tw.signIn(); | |
} | |
}); | |
}); | |
}, | |
// twitter login action | |
doLogin: function(user) { | |
$.post("twitter/login",{ | |
name : user.name, | |
location : user.location, | |
id : user.id, | |
profileImageUrl : user.profileImageUrl | |
},function(data) { | |
log("register data",data); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment