Correct way to redirect to facebook tab after authentication for app?

We have an application for holding PHP facebook ( http://apps.facebook.com/myapp). One of the pages ( http://apps.facebook.com/myapp/foobar) requires authentication from facebook, so we can access some information about the user. This is achieved using the PHP-SDK method $facebook->getLoginUrl()for generating authentication URLs and works as expected.

Since then, we have added the app as a tab (iFrame) to our page ( http://www.facebook.com/MyPage?sk=app_nnnnn). Now, when we try to authenticate the user, they are redirected to the application URL ( http://apps.facebook.com/myapp/foobar), and not to the page loading /foobarin the iFrame tab, as expected.

Is it possible to set auth so that it does not bounce off the application URL, but remains inside the Tab using the PHP-SDK? If so, what workflow should I follow to achieve this?

+3
source share
2 answers

I would just add code in http://apps.facebook.com/myapp/foobarfor authentication, and if so, echo:

<script type="text/javascript">
    top.location.href = 'http://www.facebook.com/MyPage?sk=whatever';
</script>

This should break out of the iframe and redirect you to where you want to go.

+1
source

As I did this, follow these steps:

  • On the page, /myapp/foobarI check if the user authentication has passed. If they have not set the session value and use the PHP-SDK $facebook->getLoginUrl()to generate the auth url and send a response containing only javascript for redirection window.top.
  • . , , , /myapp/foobar.

, .

0

All Articles