Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript facebook login redirect uri

I am newbie on facebook api and I make a login with facebook application but when I enter any page api redirect main page . I want to stay page that I was . forexample :

I'm in main/news/nba-orlando page and I want to login with facebook and I click the button then popup show. If i accept, api redirect main bu I want to stay main/news/nba-orlando page ... how can I do that ?

FB.init({
    appId        : '{api_id}',
    redirect_uri : document.URL,
    cookie       : true,
    xfbml        : true,
    version      : 'v2.5'
});
like image 475
maviofis Avatar asked Dec 01 '25 09:12

maviofis


1 Answers

FB.init is only for initializing the JavaScript SDK and there is no redirect_uri parameter as you can see in the docs. FB.login is for login, you can redirect with JavaScript after login:

FB.login(function(response) {
    if (response.authResponse) {
        //user just authorized your app
        window.location.href = 'xxx';
    }
}, {scope: 'email'});

More information: http://www.devils-heaven.com/facebook-javascript-sdk-login/

like image 70
andyrandy Avatar answered Dec 05 '25 17:12

andyrandy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!