English 中文(简体)
Faceoauth javascript redirect,造成无休止的失眠
原标题:Facebook oauth javascript redirect resulting in endless loop

如果用户删除了我所需要的任何许可,我想将用户转至 o页。

出于某种原因,在我试图从FB.api呼救功能中转出时,以下的法典造成了无休止的漏洞。 我如何解决这一问题的想法?

var perms           = [ publish_actions ,  email ,  user_birthday ,  user_location ],
    permsString     = perms.join( , ),
    permissionsUrl  =  https://www.facebook.com/dialog/oauth ;
    permissionsUrl  +=  ?client_id=  + config.facebook.appId;
    permissionsUrl  +=  &redirect_uri=  + encodeURI(canvasUrl);
    permissionsUrl  +=  &scope=  + permsString;

    FB.getLoginStatus(function (response) {

        if (response.status ===  connected ) {

            FB.api( /me/permissions , function(response) {

                // using underscore here...
                var keys = _.keys(response.data[0]),
                    diff = _.difference(perms, keys);

                // send the user through the auth again if they ve removed any of the perms we need
                if (diff.length) {

                    window.location.href = permissionsUrl; // results in an endless redirect loop
                    // window.location.href =  http://randomwebsite.com ; // does redirect successfully!!!!
                }
            });
        }

    }, true);
最佳回答

这是自我这样做以来的一段时期,但从记忆中,我以这样的方式解决了这一问题:

var redirectMe = function (link) {
  window.location.href = link;
};

FB.getLoginStatus(function (response) {
    if (response.status ===  connected ) {
        FB.api( /me/permissions , function(response) {
            if (true) {
                redirectMe( http://www.browsehappy.com );
            }
        });
    }
}, true);
问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签