I'm wondering why it seems as though the "else if" case of response.status === 'not authorized'
and the "else" case ("unknown", ie user is not logged into facebook) are not being executed. When I am logged into my app, testAPI() is called accordingly in the response.stats ===
'connected'
. However, when I open up incognito mode in Chrome, the testAPI() functions in the other else cases are not being called. Anyone know why?
window.fbAsyncInit = function() {
FB.init({
appId : 'appnumberhere', // App ID
channelUrl : '//localhost/appname/channel.php', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe('auth.authResponseChange', function(response) {
if (response.status === 'connected') {
testAPI(); // works
} else if (response.status === 'not_authorized') {
testAPI(); // not called. Nothing in console.
FB.login();
} else {
testAPI(); // not called. Nothing in console.
FB.login();
}
});
}); // end async init function
the testAPI function:
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
}
As a side note, I am also not seeing a facebook login dialogue pop up if I am not logged in, which is what I think fb.login() is supposed to invoke.
extra side note
Also, strangely, I need to have <script src="//connect.facebook.net/en_US/all.js"></script>
below the FB SDK include <script>(function(d){ var js,....</script>
and within my channel file for my app to work. Otherwise, some parts do not load. Not sure if this may be related, but it's very strange.