Search code examples
phphttp-redirectfacebook-php-sdklogout

How do I exit a FB app in PHP?


When in a FB app I want to press an html button and exit the app and go to the main FB page.

It's like a redirect. I tried the following:

 <form name="quit" action="redirectMainPage.php"> 
      <button class="quit" type="submit">Quit</button>
 </form>

and in the redirectMainPage.php there is:

<?php
    header('Location: https://www.facebook.com') ;
?>

When I do this, I stay in a blank page in my own app: https://apps.facebook.com/my_app/

I think this is fairly easy to do, but I'm stuck on this for a while and already out of ideas.


Solution

  • You need to redirect the entire page (outer Facebook frame and all) by outputting a script:

    <script>top.location.href='https://facebook.com/';</script>