2013-04-03 107 views
0

我已经创建了简单的Facebook注册页面。有没有办法检查用户是否使用JavaScript注册?检查用户是否注册Facebook

这是我的注册页面:

<div id="fb-root"></div> 
<script> 
    window.fbAsyncInit = function() { 
    // init the FB JS SDK 
    FB.init({ 
     appId  : 'xxxxxxx', // App ID from the App Dashboard 
     channelUrl : 'http://xxxxxxxxxx', // Channel File for x-domain communication 
     status  : true, // check the login status upon init? 
     cookie  : true, // set sessions cookies to allow your server to access the session? 
     xfbml  : true // parse XFBML tags on this page? 
    }); 

    // Additional initialization code such as adding Event Listeners goes here 

    }; 

    // Load the SDK's source Asynchronously 
    // Note that the debug version is being actively developed and might 
    // contain some type checks that are overly strict. 
    // Please report such bugs using the bugs tool. 
    (function(d, debug){ 
    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" + (debug ? "/debug" : "") + ".js"; 
    ref.parentNode.insertBefore(js, ref); 
    }(document, /*debug*/ false)); 


<div id="fb-root"></div> 
<script src="https://connect.facebook.net/en_US/all.js#appId={xxxxxxxx}&xfbml=1"></script> 

<fb:registration 
    fields="name,birthday,gender,location,email" 
    redirect-uri="http://xxxxxxxxxxxx" 
    width="530"> 
</fb:registration> 

谢谢。

回答

0

是的,当你加载JavaScript SDK在你的文件底部加入这一行

}); 

    // Additional initialization code such as adding Event Listeners goes here 
    FB.getLoginStatus(userStatus); 
    }; 

现在补充一点:

<script> 
     function userStatus(response) { 
      if (response.status === 'connected') { 
       //the user is logged in on facebook and has already authorized your app 
      } else if (response.status === 'not_authorized') { 
       //the user is logged in on facebook but hasn't authorized your app 
      } else { 
       //the user is not logged in on facebook so we don't know if he has granted permission to your app 
      } 
     } 
</script> 
+0

谢谢法比奥非常确实。 – C0ld

相关问题