【问题标题】:Twig file facebook in HWIOAuthBundleHWIOAuthBundle 中的 Twig 文件 facebook
【发布时间】:2014-01-08 07:45:10
【问题描述】:

我是使用 symfony2.3 和 FOSUserBundle 的 hwi / HWIOAuthBundle 的新手。 我已经成功安装,并且可以使用此文档 https://gist.github.com/danvbe/4476697

但在我的树枝页面上:

{% 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 注销按钮?

我在做什么?

【问题讨论】:

    标签: facebook symfony fosuserbundle hwioauthbundle


    【解决方案1】:

    不要使用javascript方式。只需在标签中给出您的路径即可。

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

    【讨论】:

    • @KunwarSiddharthSingh 不使用 Gara 方法如何解决?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-31
    • 1970-01-01
    • 2014-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多