1

現在、Facebook Javascript SDK を使用してユーザーをログインする方法を学習しています。最初はメールアドレスを尋ねる必要はありませんでしたが、今は必要です。他の人から読んだことをいくつか試しましたが、何もうまくいきませんでした。以前に使用したコードに問題がある可能性がありますか? 追加する最良の方法は何scope: "email"ですか?

これは私がこれまでに使用したコードです:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <title>A Facebook login test!</title>
    <link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
    <style type="text/css">
        h1 {font-family: 'Roboto', sans-serif;}
    </style>
</head>

<body>
    <div id="fb-root"></div>
    <script>
      window.fbAsyncInit = function() {
        // init the FB JS SDK
        FB.init({
          appId      : '{{ FACEBOOK_APP_ID }}',                 // App ID from the app dashboard
          channelUrl : '{{ DOMAIN }}/channel.html',                 // Channel file for x-domain comms
          status     : true,                                    // Check Facebook Login status
            cookie    : true,                                               // enable cookies to allow the server to access the session       
          xfbml      : true                                     // Look for social plugins on the page
        });

      // Here we subscribe to the auth.authResponseChange JavaScript event. This event is fired
      // for any authentication related change, such as login, logout or session refresh. This means that
      // whenever someone who was previously logged out tries to log in again, the correct case below 
      // will be handled. 
      FB.Event.subscribe('auth.authResponseChange', function(response) {
      // Here we specify what we do with the response anytime this event occurs. 
        if (response.status === 'connected') {
                  // The response object is returned with a status field that lets the app know the current
                  // login status of the person. In this case, we're handling the situation where they 
                  // have logged in to the app.

          window.location = "/fblogin";
            } 
        });
      };

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


    </script>

    <h1>This is the Facebook and Google+ login test.</h1>
    <br>
    <fb:login-button show-faces="true" width="200" max-rows="1" scope: "email"></fb:login-button>
    <br>

アプリがメール アドレスにアクセスすることを許可するようユーザーに求められないのはなぜですか?

前もって感謝します、デビッド。

4

1 に答える 1

0

あなたが書いた :<fb:login-button show-faces="true" width="200" max-rows="1" scope: "email">

これを試して:<fb:login-button show-faces="true" width="200" max-rows="1" scope= "email">

于 2013-08-25T12:25:38.743 に答える