0
votes

Hi im new to the facebook api and have managed to get a user to login using facebook, however I am trying to make a logout that redirects to a different page eg. logout.php The issue is when it logs out it redirects to the same page.

The code im using to get the logout link is:

$logoutUrl = $facebook->getLogoutUrl();

How can i make it so the logout url automatically logs you out of facebook and redirects you to logout.php?

Thanks in advance!

UPDATE

An example of the url i currently get from the getLogoutUrl() function:

https://www.facebook.com/logout.php?next=http%3A%2F%2FMYDOMAINHERE.com%2F&access_token=MYACCESSTOKENHERE

My guess is that if i can pass it a redirection URL to autogenerate with that function it would look something like this:

https://www.facebook.com/logout.php?next=http%3A%2F%2FMYDOMAINHERE.com%2FLOGOUT.PHP%2F&access_token=MYACCESSTOKENHERE

UPDATE

Never mind i just figured it out. Works the same way the login does with the

getLogoutUrl(array(
                   'next' => 'http://' . $_SERVER['HTTP_HOST'] . '/logout.php'
                   ));
1

1 Answers

0
votes

Do you mean this?:

header ("Location: $logoutUrl")
exit;