Created
August 8, 2012 07:17
-
-
Save mattlanham/3293052 to your computer and use it in GitHub Desktop.
Quick example of use
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
// Put this in app.js | |
Ti.Facebook.appid = 'xxxxxxxxxxxxx'; | |
// Add a login button somewhere and put the following code inside it | |
Parse.FacebookUtils.init({}); | |
Parse.FacebookUtils.logIn(['publish_stream', 'email', 'read_friendlists', 'publish_actions'], { | |
success: function(user) { | |
Ti.Facebook.requestWithGraphPath('me?fields=name,email,picture,username', {}, 'GET', function(e) { | |
var result = JSON.parse(e.result); | |
var user = Parse.User.current(); | |
var aliases = user.get('aliases'); | |
if(!_.include(aliases, result.username + '@facebook.com')) { | |
aliases.push(result.username + '@facebook.com'); | |
} | |
if(!_.include(aliases, result.email)) { | |
aliases.push(result.email); | |
} | |
user.save({ | |
name: result.name, | |
email: result.email, | |
aliases: aliases, | |
picture: result.picture | |
}, | |
{ | |
success: function( user ){ | |
}, | |
error: function(user, error){ | |
//alert('error ' + JSON.stringify(error)); | |
} | |
}); | |
self.close(); | |
init(); | |
}); | |
if (!user.existed()) { | |
} else { | |
// alert("User logged in through Facebook!"); | |
} | |
}, | |
error: function(user, error) { | |
//alert("User cancelled the Facebook login or did not fully authorize."); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment