views:

766

answers:

3

Hello Guys!

any FB experts here? After reading about 15 thread on FB forums I don'T know where to go next =(

We have an iFrame FB app: http://apps.facebook.com/myapp

all links used in app are like: href="http://www.mysite.com/index.php?parm=value ..."

now when I click on any link, I am out of facebook and land on our server.

Don't really know how to solve this! using links with facebook server ins't an option.

Thanks guys for some hints!

A: 

Do you mean clicking a link in the iframe goes to your site intead? If you do you could try setting the "target" attribute of the html anchor to "_self" which should open the link in the iFrame.

Robert
A: 

I was having this problem. After appending all the FB querystring parameters from the initial IFrame to each of the urls in my links, they started opening in the right windows.

See here for an example http://www.keywordintellect.com/facebook-development/facebook-iframe-authentication-across-pages-ajax-requests/

mcintyre321
+1  A: 

This is because Facebook loses all of the authentication variables and is unable to determine that the concurrent requests belong to the same session, which results in "breaking out" of the iframe and ending up on your own server pages instead of within Facebook.

Anytime a page is served through Facebook, the request received at your server will include a number of GET variables sent by Facebook, these variables are collectively known as the "Facebook Authentication Signature" which proves to your server that the request actually is valid and originated from Facebook; likewise, when your server sends the response, the inclusion of these variables proves to Facebook (by a combination of the session_key, api_key, and sig digest) that your server is the application it claims to be.

In order to persist the session within your iframe app without breaking out to your server, you must include these parameters on each link's query string. Here is a simple function that will produce the query string for you, so you simply need to append the result of this function to each link URL in your application:

function fb_sig_urlQueryString() {
  $query = '';
  foreach ($_GET as $k => $v) {
    if (strpos($k, 'fb_sig') === 0) {
      if ($i++ > 1) $query .= '&';
      $query .= $k.'='.$v;
    }
  }
}
Dustin Fineout