2013-02-20 37 views
1

我的Facebook連接有點問題,關於生日許可。Facebook連接生日燙髮

上的HTML身體,我有:

<div class="fb-login-button" scope="user_birthday, user_about_me" perms="email,user_birthday"> Login with Facebook </div> 

頁眉,對於JS,我有:

<script> 
    // Additional JS functions here 

    window.fbAsyncInit = function() { 
     FB.init({ 
      appId  : 'XXXXXXX', // App ID 
      channelUrl : '//connect.facebook.net/en_US/all.js', // Channel File 
      status  : true, // check login status 
      cookie  : true, // enable cookies to allow the server to access the session 
      xfbml  : true // parse XFBML 
     }); 

     // Additional init code here 
     FB.getLoginStatus(function(response) { 
      if (response.status === 'connected') { 
       // connected 
       FB.api('/me??accessToken='+response.authResponse.accessToken, function(user) { 
        var monthfb = user.birthday.substr(0,2); 
        var dayfb = user.birthday.substr(3,2); 
        var yearfb = user.birthday.substr(6,4); 

        $("input[id=year]").val(monthfb); 
        $("input[id=month]").val(dayfb); 
        $("input[id=day]").val(yearfb); 

        $("a.age_gate_submit").click(); 
        alert('1'); 

        console.log(user); 
        //$.cookie('age_gate', 'gohome',{ expires: 99 }); 
        window.location = "home.html"; 
       }); 
      } 
     }); 
    }; 

    function login() { 
     FB.login(function(response) { 
      if (response.authResponse) { 
       // connected 
       FB.api('/me??accessToken='+response.authResponse.accessToken, function(user) { 
        var monthfb = user.birthday.substr(0,2); 
        var dayfb = user.birthday.substr(3,2); 
        var yearfb = user.birthday.substr(6,4); 



        $("a.age_gate_submit").click(); 
        alert('2'); 

        //console.log(response.birthday); 
        console.log(user); 
        //$.cookie('age_gate', 'gohome',{ expires: 99 }); 
        window.location = "home.html"; 
       }); 
     } 
     }); 
    } 

    // Load the SDK Asynchronously 
    (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#xfbml=1&appId=XXXXXXX"; 
     ref.parentNode.insertBefore(js, ref); 
    }(document)); 


</script> 

當我點擊我的按鈕,我有很好的窗口,我接受FB應用程序,但沒有任何jS調用的函數,所以window.locations不起作用。但是,當我刷新它沒關係,我可以採取生日等等...所以問題就在我接受該應用程序的那一刻:請問如何重定向?

+0

您的問題沒有明確的 - 究竟是什麼不是。加工? – Igy 2013-02-20 23:39:32

回答

1

對不起,你的回答沒有幫助我。 但我找到了解決辦法:

我不得不實施FB.Event.subscribe(),此功能時,一個人接受日誌中