Question:

I am using the PHP SDK to build my iFrame canvas application. The following code is used to redirect the user to do the login:

$url = $facebook->getLoginUrl();
     echo "<script type='text/javascript'>top.location.href = '$url';</script>";    

However, after performing the logon, the user will leave apps.facebook.com and access my application directly (i.e. the URL in the browser is something like http://www.mystite.com/myapp/index.php instead of http://apps.facebook.com/myapp/index.php).

What is wrong?

 

 

Answer:

Appreciate if you can like this page if you find it useful! - Click "Like"

When calling the getLoginUrl method, we need to tell the PHP SDK that we are getting the login URL for a "canvas, non-FBConnect" application by specifying "canvas => 1 " and "fbconnect => 0".

For the details, please see: http://www.takwing.idv.hk/tech/fb_dev/phpsdk/learning_phpsdk_06.php

 

Find my FAQ on Facebook Development useful? Download the PDF for all the FAQs HERE!