2014-01-08 30 views
0

我是新的與hwi/HWIOAuthBundle與symfony2.3和FOSUserBundle。 我已經成功地安裝和這個工作的罰款與此文檔https://gist.github.com/danvbe/4476697在HWIOAuthBundle的樹枝文件的facebook

,但在我的樹枝頁:

{% block content %} 
<script> 
window.fbAsyncInit = function() { 
    // init the FB JS SDK 
    FB.init({ 
     appId  : 'xxxxxxxxx',      // App ID from the app dashboard 
     channelUrl : 'xxxxxxxxx',  // Channel file for x-domain comms 
     status  : true,         // Check Facebook Login status 
     xfbml  : true         // Look for social plugins on the page 
    }); 
}; 
// Load the SDK asynchronously 
(function(d, s, id){ 
    var js, fjs = d.getElementsByTagName(s)[0]; 
    if (d.getElementById(id)) {return;} 
    js = d.createElement(s); js.id = id; 
    js.src = "//connect.facebook.net/en_US/all.js"; 
    fjs.parentNode.insertBefore(js, fjs); 
}(document, 'script', 'facebook-jssdk')); 
function fb_login() { 
    FB.getLoginStatus(function(response) { 
     if (response.status === 'connected') { 
      // connected 
      alert('Already connected, redirect to login page to create token.'); 
      document.location = "{{ url("hwi_oauth_service_redirect", {service: "facebook"}) }}"; 
     } else { 
      // not_authorized 
      FB.login(function(response) { 
       if (response.authResponse) { 
        document.location = "{{ url("hwi_oauth_service_redirect", {service: "facebook"}) }}"; 
       } else { 
        alert('Cancelled.'); 
       } 
      }, {scope: 'email'}); 
     } 
    }); 
} 
</script> 
<p> 
<a href="#" onclick="fb_login();">Facebook Connect Button (Dialog)</a> 
</p> 
{# Bonus: Show all available login link in HWIOAuthBundle #} 
{% render(controller('HWIOAuthBundle:Connect:connect')) %} 
{% endblock %} 

該頁面顯示Facebook的標誌,當我點擊,然後告訴我的Facebook登錄頁面,登錄後重定向到再次登錄頁面bcoz我設置默認重定向登錄但我的問題是登錄後沒有顯示Facebook登出按鈕?

我在做什麼?

回答

2

請勿使用javascript方式。只要給你的標籤路徑。

<a href="{{ url("hwi_oauth_service_redirect", {service: "facebook"}) }}">Facebook Connect Button (Dialog)</a> 
+0

@KunwarSiddharthSingh如何解決而不使用Gara方法? – tttony