FB.api returns undefined for response.name

I am creating a facebook application in an iframe. The page basically works, but I want to use the username currently registered on the page for custom posts, etc.

I load the FB library as follows:

 <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 a page in sandbox mode, but two out of 4 people get FB.getLoginStatus = Connected, and the other two get FB.getLoginStatus = NotConnected.

For those who are not connected, when I call FB.api, it returns 'undefined' as the username:

 function testFBLoggedIn() {
  //http://developers.facebook.com/docs/reference/api/user
  FB.api('/me', function(response) {
   alert(response.first_name);
                }
        }

, , - , _, last_name . , , .

- - , facebook, ?

.

+3
2

, /me, .

/uid , , , uid.

, , .

+4

, API/me/friends, test user, , . Facebook, .

, , . , , Facebook.

0

Source: https://habr.com/ru/post/1766028/


All Articles