2013-05-21 4 views
1

페이스 북으로 로그인하려면 웹 사이트를 만들어야합니다. 그 (것)들에게 전자 우편을 보내기 위하여 이해 될 수있다, 그러나 나는 페이스 북에서 이메일 주소를 얻을 수 없다.Facebook API는 이메일 주소를 얻습니다

정확하게 지침을 따랐습니다. https://developers.facebook.com/docs/facebook-login/getting-started-web/ FB.login에 {scope : email}을 추가합니다.

Facebook API를 사용하여 이메일 주소를 얻으려면 어떻게해야합니까? 지금 쯤

내 코드

: 성공적으로 로그인 한 경우

<div id="fb-root"></div> 
<script> 

    window.fbAsyncInit = function() { 
    FB.init({ 
    appId  : 'app', // App ID 
    channelUrl : '//domain.COM/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') { 


    FB.api('/me', function(response) { 

     console.log(response); 
    }); 

    } else if (response.status === 'not_authorized') { 

     FB.login(function(response) {},{scope: 'email'}); 

    } else { 


     FB.login(function(response) {}, {scope: 'email'}); 


    } 
    }); 
    }; 

    // Load the SDK asynchronously 
    (function(d){ 
    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; 
    if (d.getElementById(id)) {return;} 
    js = d.createElement('script'); js.id = id; js.async = true; 
    js.src = "//connect.facebook.net/en_US/all.js"; 
    ref.parentNode.insertBefore(js, ref); 
    }(document)); 

    </script> 
    <fb:login-button show-faces="true" width="200" max-rows="1"></fb:login-button> 

답변

0

, 사용자의 이메일 주소를 반환합니다 response.email를 호출.

+0

하는 데 도움이

} else if (response.status === 'not_authorized') { FB.login(function(response) {},{scope: 'email'}); } else { FB.login(function(response) {}, {scope: 'email'}); } 

희망을 (응용 프로그램에 권한이 부여 된 후 FB.login에 이메일을 ... 난 좋은 생각하지 않는 범위 추가) . 응답에서 나는 기초가있다. – Alqin

+0

response.status가 연결된 경우 console.log (응답)의 출력은 무엇입니까? –

1

동일한 문제가 발생했습니다. fb 계정에서 앱을 인증 해제합니다. 그런 다음 테스트 페이지를 통해 앱을 다시 승인하십시오.

앱을 처음 승인 한 후에는 아래 블록을 찾지 못했습니다. 내가 거기에 이메일 객체가없는 문제가 있다고

관련 문제