Return to previous page after logging into facebook oauth

1

I use the default login system, it asks you to insert App ID and App Secret the URL that will return after requesting the login to the user, my doubt is, how to do to return the url in which the login was requested. on several pages will be the Login button, then I would like you to return the source page. How do I?

    
asked by anonymous 20.07.2015 / 00:11

1 answer

1

If you are generating the login link via php, just change it dynamically.

For example, the news page is:

$helper = new FacebookRedirectLoginHelper('http://seusite/noticia.php');
$loginUrl = $helper->getLoginUrl();
...

and in the same one to receive / check the user back it stays:

if ( !empty($_GET['code']) ){
...
$helper = new FacebookRedirectLoginHelper('http://seusite/noticia.php');
try {
  $session = $helper->getSessionFromRedirect();
} catch
...

* When facebook returns from login it brings this variable GET

Note: Actually this second piece of code I put in must come before the first one. If you have $ _GET ['code'] (and / or a session variable that you will use to save the login token) log in, if not, it will generate the login link (the link that will have the button) / p>     

22.07.2015 / 00:14