0

방금 ​​페이스 북 API를 사용하기 시작했는데 API를 사용하여 FB.User 객체를 사용하여 이메일을 알릴 수 없습니다. 내 userID와 내 이름을 인쇄 할 수는 있지만 이메일이나 교육을 인쇄하려고하면 정의되지 않은 값을 반환합니다. 여기에 내 코드입니다 :Facebook 자바 스크립트 SDK를 통해 이메일 받기

<html> 
<head> 
    <script src ="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 

</head> 
<body> 

<div id="fb-root"></div> 
<script> 
    var appId = '1374555416100192'; 
    var siteRoot = ''; 

    window.fbAsyncInit = function() { 
    FB.init({ 
     appId  : appId, 
     channelURL : '///channel.html', // Channel File 
     status  : true, 
     cookie  : true, 
     oauth  : true, 
     xfbml  : true 
    }); 
    $(document).trigger('fbload'); 
    }; 


    (function(d){ 
    var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} 
    js = d.createElement('script'); js.id = id; js.async = true; 
    js.src = "http://connect.facebook.net/en_US/all.js#xfbml=1&appId=" + appId; 
    d.getElementsByTagName('head')[0].appendChild(js); 
    }(document)); 



    $(document).on(
    'fbload', // <---- HERE'S OUR CUSTOM EVENT BEING LISTENED FOR 
    function(){ 
     //some code that requires the FB object 
     //such as... 
     FB.getLoginStatus(function(res){ 
      if(res.status == "connected"){ 
       FB.api('/me', function(fbUser) { 
        alert(fbUser.name + " " + fbUser.email); 
       }); 
      } 
     }); 

    } 
); 
</script> 


<div class="fb-login-button" data-show-faces="true" data-width="200" data-max-rows="1">Start w/ Facebook</div> 

</body> 
</html> 

답변

4

당신은

<div class="fb-login-button" data-scope="email" data-show-faces="true" data-width="200" data-max-rows="1">Start w/ Facebook</div> 
그것을

변경

<div class="fb-login-button" data-show-faces="true" data-width="200" data-max-rows="1">Start w/ Facebook</div> 

으로 아래의이 행을 액세스하고 (추가 data-scope="email")을 확인하기 위해 이메일 권한이 필요합니다

관련 문제