javascript - Facebook JS API - How to redirect user after login - Stack Overflow

I have the following code:FB.getLoginStatus(function (response) {if (response.session) {} else {FB.ui({

I have the following code:

FB.getLoginStatus(function (response) {
            if (response.session) {
            } else {
                FB.ui({
                    method: 'oauth',
                    perms: 'email,publish_stream',
                    },
                    function (response) {
                        if (response && response.installed) {
                           window.location.reload();
                        }
                    });
            }
        });

What I want is to basically redirect the user to the same page so that the serverside can use the REST API. Is there anyway to make this work?

I have the following code:

FB.getLoginStatus(function (response) {
            if (response.session) {
            } else {
                FB.ui({
                    method: 'oauth',
                    perms: 'email,publish_stream',
                    },
                    function (response) {
                        if (response && response.installed) {
                           window.location.reload();
                        }
                    });
            }
        });

What I want is to basically redirect the user to the same page so that the serverside can use the REST API. Is there anyway to make this work?

Share Improve this question asked Apr 25, 2011 at 19:49 RaphaelRaphael 8,20214 gold badges64 silver badges86 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

Subscribe to the login event:

FB.Event.subscribe('auth.login', function (response) {
  window.location.reload();
});

Use this.

FB.Event.subscribe('auth.sessionChange', function (response) {
   if (response.session) {
       //user is logged in!
       window.location = document.URL;
   }
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744743203a4591151.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信