2011-10-29 10 views
0

Facebookのユーザーログインフローのどの時点で自分のデータを保存できるかを調べようとしています。私のアプリは私たちに連絡できるようにユーザーの電子メールを要求しますが、のコードでは自分の情報をデータベースに保存することになっています。Facebookのログイン時にユーザーデータを保存する

そして、ここではそれが再びです:あなたが与えているコードから

<script> 
    window.fbAsyncInit = function() { 
    FB.init({ 
     appId  : '255450714496176', // App ID 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     oauth  : true, // enable OAuth 2.0 
     xfbml  : true // parse XFBML 
    }); 

     FB.getLoginStatus(function(response) { 
      if (response.authResponse) { 
      // logged in and connected user, someone you know 
      FB.api('/me', function(response) { 
       alert("Welcome, " + response.name); 
      }); 
      } else { 
      // no user session available, someone you dont know 
      alert("logged out"); 
      } 
     }); 
     FB.Event.subscribe('auth.authResponseChange', function(response) { 
      alert('The status of the session is: ' + response.status);   
     }); 

    }; // fbAsyncInit 

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

</script> 

答えて

0

、あなたはif(response.authResponse)ブロック内で、FB.getLoginStatusにデータを格納することができます。

関連する問題