权限url回调登录使用自定义HTML按钮

时间:2012-07-30 18:02:51

标签: javascript facebook facebook-graph-api

我有一个Facebook按钮刷新我的网址on-login

<fb:login-button perms="email,user_about_me,user_photos" on-login="window.location = 'http://myDomain.com';">Login</fb:login-button>

但如果我不想使用标准的facebook按钮并决定使用我自己的标记与javascript
我似乎很难在登录时收到回叫 继承我的尝试,任何建议或帮助总是受到赞赏 感谢

function fb_oAuth(){
    FB.ui({
            method: "permissions.request", 
            "perms": 'email, user_about_me, user_photos'
        } , function(response) { 
        console.log(response); 
        /* if (response.session) {
                    window.location.href = 'http://www.myDomain.com';
                }  */
        });

        /*  FB.Event.subscribe('auth.sessionChange', function(response) {
                if (response.session) {
                    window.location.href = 'http://www.myDomain.com';
                } else {
                    // The user has logged out, and the cookie has been cleared
                }
        }); */

});

// HTML button
<a href="#" onClick="fb_oAuth(); event.preventDefault();">Login with Facebook</a>

1 个答案:

答案 0 :(得分:0)

使用FB.login作为方法权限.request方法不适用于您的方案。检查FB dev。 docs以获取更多信息。