2012-07-31 4 views
1

내 응용 프로그램에 FBConnect를 통합하는 데 성공했습니다. 연결 및 등록 페이지가 정상적으로 작동했습니다.Facebook 연결 통합이 더 이상 작동하지 않습니다.

하지만 잠시 동안 페이 스북 버튼을 클릭하면 내가 묶어 놓은 이벤트가 더 이상 발생하지 않습니다.

<script src="http://connect.facebook.net/fr_FR/all.js" ></script> 
<script type="text/javascript"> 
//console integration 
if(typeof console !== 'object') 
console = {}; 
if((typeof console.debug) !== 'function'){ 
    if(typeof opera === 'object'){ 
     console = { 
      debug : function(){return opera.postError(arguments);}, 
      info : function(){this.debug('[INFO] ',arguments);}, 
      log : function(){this.debug('[LOG] ',arguments);} 
     }; 
    } 
    else{ 
     console = { 
      debug : function(){return true;}, 
      info : function(){return true;}, 
      log : function(){return true;} 
     }; 
    } 
} 

/** 
* Fonction called to init and manage FB Connection 
*/ 
handleFacebook(); 
$('#fb-button').click(function(){ 
    alert('ok'); 
    fbGetLoginStatus(); 
}); 

/** 
* 
*/ 
function handleFacebook() { 
    if(!window.fbApiInit) { 
     FB.init({appId: 'myAppId', xfbml: true, cookie: true}); 
     fbApiInit = true; 
    } 
} 

function fbGetLoginStatus() { 
    FB.getLoginStatus(function(response) { 
     onStatus(response); // once on page load 
     FB.Event.subscribe('auth.statusChange', onStatus); // every status change 
    }); 
} 

/** 
* This will be called once on page load, and every time the status changes. 
*/ 
function onStatus(response) { 
    console.info('onStatus', response); 
    if (response.status == 'connected') { 
     console.info('User logged in'); 
     if (response.perms) { 
      console.info('User granted permissions'); 
     }else{ 
      console.info('User has not granted permissions'); 
     } 
     getAccountInfo(); 
    } else { 
     console.info('User is logged out'); 
    } 
} 

/** 
* This assumes the user is logged out, and renders a login button. 
*/ 
function showLoginButton() { 
    var button = '<fb:login-button perms="email" />'; 
    $('#fb-login-button').html(button); 
    FB.XFBML.parse(document.getElementById('fb-login-button')); 
} 

function getAccountInfo() { 
    FB.api(
     { 
     method: 'fql.query', 
     query: 'SELECT username, first_name, last_name, uid, email, sex FROM user WHERE uid='+FB.getUserID() 
     }, 
     function(response) { 
      console.info('API Callback', response); 
      var user = response[0]; 

      $('#usernamefb').val(user.username); 
      $('#mailfb').val(user.email); 

      $('#facebook-connect-form').submit(); 
     } 
    ); 
} 
</script> 
<div id="fb-login-button"> 
    <fb:login-button perms="email" id="fb-button" /> 
</div> 
<form method="post" action="/facebook-connect" id="facebook-connect-form"> 
    <input type="hidden" id="usernamefb" name="usernamefb"/> 
    <input type="hidden" id="mailfb" name="mailfb"/> 
</form> 

은 내가 $에서 경고 기능 ('#의 FB-버튼'). 이벤트가 호출되지 않습니다 클릭 것을 알 수 있습니다. 여기에는 나와 있지 않지만 내 파일에는 jQuery 라이브러리 상단이 포함되어 있습니다. 아이디어가 있으십니까?

답장을 보내 주셔서 감사합니다.

답변

0

Facebook의 버튼이 변경되어 변경 후 클릭 이벤트를 바인딩하는 방법을 찾지 못했습니다.

내 웹 사이트를 FB 이벤트로드에 가입하도록 변경했습니다. FB를 초기화 할 때 옵션 "상태"를 false로 설정하여 초기화시 자동 Loginstatus-Check를 방지해야합니다!

function fbInit() { 
     window.fbAsyncInit = function() { 
      FB.init({ 
       appId: 'XXX', 
       status: false, 
       cookie: true, 
       xfbml: true 
      }); 

      //auth.statusChange 
      FB.Event.subscribe('auth.authResponseChange', function (response) { 
       if (response.status.indexOf('connected') != -1) { 
        // the user is logged in and has authenticated your 
        // app, and response.authResponse supplies 
        // the user's ID, a valid access token, a signed 
        // request, and the time the access token 
        // and signed request each expire 
        var uid = response.authResponse.userID; 
        var accessToken = response.authResponse.accessToken; 

        //Handle the access token 
        jQuery.ajax({ 
         url: 'token_handler.ashx', 
         type: 'POST', 
         data: "accessToken=" + accessToken, 
         success: function (msg) { 

         } 
        }); 

       } else if (response.status.indexOf('not_authorized') != -1) { 
        // the user is logged in to Facebook, 
        // but has not authenticated your app 
       } else { 
        // the user isn't logged in to Facebook. 
       } 
      }); 
     }; 
    (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)); 
} 
관련 문제