2013-09-23 30 views
0

我正在开发一个Web应用程序,我已经从developers.facebook.com实施Facebook登录,但事情是,每当用户登录与他Facebook的凭据,它不会重定向到我的应用程序,我也试图在我的IDE本地进行测试,但即使我无法做到这一点。有没有什么办法让它以及我在寻找注销选项,因为我想在用户登录后添加注销按钮。任何帮助将不胜感激。提前致谢。Facebook登录按钮添加到我的应用程序,但不会重定向一旦用户登录

,这里是我的登录代码:

HTML:

<div id="fb-root"></div> 

<div class="fb-login-button" data-width="500"></div> 

和我的JS代码:

window.fbAsyncInit = function() { 
    // init the FB JS SDK 
    FB.init({ 
    appId  : '425369200906567',      // App ID from the app dashboard 
    channelUrl : 'channel.html', // Channel file for x-domain comms 
    status  : true,         // Check Facebook Login status 
    xfbml  : true         // Look for social plugins on the page 
    }); 

    // Additional initialization code such as adding Event Listeners goes here 
    }; 

    // 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(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_GB/all.js#xfbml=1&appId=425369200906567"; 
    fjs.parentNode.insertBefore(js, fjs); 
    }(document, 'script', 'facebook-jssdk')); 

回答

0

,如果你想要做的事,一旦用户登录到您的应用程序(您的案例重定向到另一页应用程序页面您可以使用response.authResponse来做到这一点

FB.login(function(response) { 
     if (response.authResponse) { 
      // when the user logs in! & gives permission 
      // Do something 
     alert('Change this alert to "windows.location"') 
     } else { 
      // when the user doesn't give the required permissions 
      // Do something 
     alert('User canceled login or did not fully authorize the app.'); 

     } 
    }, { scope: 'user_photos, publish_stream' }); // App's permission 

Fiddle

+0

我尝试了这些例子,但即使我已经更新了小提琴。但它不重定向。有什么建议么。? http://jsfiddle.net/Ct7sV/1/ –

+0

[试试这个(添加/显示到永久链接](http://jsfiddle.net/Ct7sV/3/show/)(问题是,jsFiddle使用iframe打破了函数'windows.location'&'windows.open') –

+0

非常感谢你真的很好,但我不能在本地测试它,因为我没有在Facebook中编辑应用程序详细信息中提供任何网站URL位置。我认为我的应用程序存在一些问题http://jsfiddle.net/Ct7sV/4/ –

相关问题