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 and access my application directly (i.e. the URL in the browser is something like instead of

What is wrong?




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:


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