I'm creating a facebook app in an iframe. The page is mostly working, but I want to use the currently logged in user's name in the page, for custom messaging, etc.
I'm loading the FB library like this:
<div id="fb-root"></div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" >
FB.init({
appId : '106832082707477',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.getLoginStatus(function(response) {console.log("FB.getLoginStatus=" + response.status)});
</script>
I currently have the page in sandbox mode, but two of the 4 people receive FB.getLoginStatus=Connected, while the other two get FB.getLoginStatus=NotConnected.
For those who are not connected, when I call FB.api, it returns 'undefined' as the user name:
function testFBLoggedIn() {
//http://developers.facebook.com/docs/reference/api/user
FB.api('/me', function(response) {
alert(response.first_name);
}
}
I would really not like to have to have the user log into my application, since I'm not trying to access anything more than their first_name, last_name, and name user properties. Plus, this is an extra step for users to have to do and we've already sold the client on the current process.
Does anyone have any ideas as to how to consistently get a handle on the facebook user name barring throwing up an allow box?
Thanks.