-2

Facebook でログインを使用するアプリを作成しましたが、ユーザーのメール アドレスを取得できません。スコープを使用する必要があることはわかっていますが、方法がわかりません。これどうやってするの?これは私のコードです:

 window.fbAsyncInit = function() {
  FB.init({
     appId      : '<?= $this->getAppId(); ?>', // App ID
     channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
     status     : true, // check login status
     cookie     : true, // enable cookies to allow the server to access the session
     xfbml      : true,  // parse XFBML
     oauth     : true

   });
   FB.Event.subscribe('auth.authResponseChange', function(response) {
     // Here we specify what we do with the response anytime this event occurs. 
     if (response.status === 'connected') {
        testAPI();
     } else if (response.status === 'not_authorized') {
       FB.login()
     } else {
        FB.login()

     }
   });
   }

   // 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));

   // Here we run a very simple test of the Graph API after login is successful. 
   // This testAPI() function is only called in those cases. 
   function testAPI() {
     console.log('Welcome!  Fetching your information.... ');
     FB.api('/me', function(response) {
       console.log('Good to see you, ' + response.name + '.');
       console.log( response.email);
     });
   }
4

2 に答える 2