YAHOO.util.Event.onDOMReady(function() { FB.init({ appId:116947108385155, cookie:true, status:true, xfbml:true }); FB.getLoginStatus(function(response) { if (response.session) { // logged in and connected user, someone you know YAHOO.log('User logged in to Facebook and connected to our authentication app', 'info', 'fbDetect'); YAHOO.util.Connect.asyncRequest( 'GET', '/component/user?view=ajax&tmpl=component&format=raw&action=autoLogin&fbId=' + response.session.uid, { success: function(o) { YAHOO.log(o.responseText, "info", "fbDetect"); var r = YAHOO.lang.JSON.parse(o.responseText); switch (r.status) { case 200: /** User has a linked account and has been auto logged in **/ YAHOO.log('Linked user auto-logged in', 'info', 'fbDetect'); break; case 301: /** Not a linked user **/ YAHOO.log('Not a linked user', 'info', 'fbDetect'); break; } }, failure: function(o) { YAHOO.log('Async request connection failure: ' + o.responseText, "debug", "fbDetect"); }, scope: this } ); } else { // no user session available, someone you dont know YAHOO.log('Not a connected user - No response.session', 'info', 'fbDetect'); } }); });