仅提示登录一次

时间:2013-02-06 01:02:36

标签: android facebook login

我有一个视频播放器应用。单击某个视频时,系统会提示用户使用以下代码登录其Facebook帐户:

if(videoCode == "BQXTCCyJsKE"){
$(document).ready(function () {
  login() 
});
}

登录功能正常工作但是当再次点击相同的视频缩略图时,登录过程当然会再次运行,这会产生错误。有没有人知道如何处理这个问题?通过布尔逻辑还是通过Facebook API? API代码和被调用的函数都在下面。

<div id="fb-root"></div>
<script type="text/javascript">
//<![CDATA[
window.fbAsyncInit = function() {
   FB.init({
     appId      : '410375775693910', // App ID
     channelURL : '', // Channel File, not required so leave empty
     status     : true, // check login status
     cookie     : true, // enable cookies to allow the server to access the session
     oauth      : true, // enable OAuth 2.0
     xfbml      : false  // parse XFBML
   });

};
// logs the user in the application and facebook
function login(){
FB.getLoginStatus(function(r){
     if(r.status === 'connected'){
            window.location.href = 'fbconnect.php';
     }else{
        FB.login(function(response) {
                if(response.authResponse) {
              //if (response.perms) 
                    window.location.href = 'fbconnect.php';
            } else {
              // user is not logged in
            }
     },{scope:'email'}); // which data to access from user profile

 }
});
}
// Load the SDK Asynchronously
(function() {
   var e = document.createElement('script'); e.async = true;
   e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';                 
   document.getElementById('fb-root').appendChild(e);
}());
//]]>
</script>

0 个答案:

没有答案