Return to Snippet

Revision: 61736
at January 11, 2013 00:30 by boardmain


Initial Code
var Cloud = require('ti.cloud');
Titanium.Facebook.appid = "285243484913611";//Production
Titanium.Facebook.permissions = ['publish_stream', 'read_stream'];
 
var win = Ti.UI.createWindow({
	title : "ACS Social Integrations"
});
 
var fbSignupBtn = Ti.UI.createButton({
	title : "Login with Facebook",
	width : 160,
	top : 50
});
win.add(fbSignupBtn);
 
fbSignupBtn.addEventListener('click', function() {
	if (!Titanium.Facebook.loggedIn) {
		Titanium.Facebook.authorize();
	}
});
 
//add SocialIntegrations in Facebook login event listener
Titanium.Facebook.addEventListener('login', function(e) {
	if (e.success) {
		alert("login Success ");
		//code for SocialIntegrations
	} else if (e.error) {
		alert("Error = " + e.error);
	} else if (e.cancelled) {
		alert("Canceld");
	}
});
 
win.open(); 



///
STEP2

Titanium.Facebook.addEventListener('login', function(e) {
	if (e.success) {
		Cloud.SocialIntegrations.externalAccountLogin({
			type : 'facebook',
			token : Ti.Facebook.accessToken
		}, function(e) {
			if (e.success) {
				var user = e.users[0];
				Ti.API.info('User  = ' + JSON.stringify(user));
				Ti.App.Properties.setString('currentUserId', user.id);
				alert('Success: ' + 'id: ' + user.id + '\\n' + 'first name: ' + user.first_name + '\\n' + 'last name: ' + user.last_name);
			} else {
				alert('Error: ' + ((e.error && e.message) || JSON.stringify(e)));
			}
		});
	} else if (e.error) {
		alert("Error = " + e.error);
	} else if (e.cancelled) {
		alert("canceld");
	}
});

Initial URL

                                

Initial Description
Utilizzare il login d facebook in icloud appcelerator

Initial Title
Integrarare il Login di Facebook nel Cloud Titanium

Initial Tags
facebook

Initial Language
JavaScript