views:

1056

answers:

2

i'am having trouble with facebook php-sdk new api, permission window i am using facebook connect inside the facebook iframe application

http://tinyurl.com/2aojf5l

when i try to login with following url login windows laying out well inside facebook application but permission diolog is being overlayed by shaded screen

what can cause this ? any clue i am using only php no javascript facebook api

thanks

+1  A: 

I had the same problem. To fix it, you'll need to use JS to redirect the user to the FB authorization page, then let FB pass the authenticated user back to your app page. You don't need to use the JS API for this.

  • First, check the FB applications settings and make sure that your "Post-Authorize Redirect URL" is set to your Canvas Page URL. (e.g. http://apps.facebook.com/[YOUR APP]/)

  • Then handle your authentication like this:

    $session = $facebook->getSession(); $me = null; if ($session){ try { $uid = $facebook->getUser(); $me = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); } }

    if ($me) { $logoutUrl = $facebook->getLogoutUrl(); } else { $loginUrl = $facebook->getLoginUrl( array('next'=>"http://apps.facebook.com/[YOUR APP]/")); }

    if (!$me){ print("[html][head]");
    print("[script type=\"text/javascript\"]function redirect(){ top.location.href = \"");
    print($loginUrl);
    print("\"; }[/script][/head]");
    print("[body onload=\"redirect();\"]Please wait...[/body][/html]"); exit(); }

( i dunno how to make tags appear here, so i used square brackets. you'll want to replace those)

eddie
+1  A: 

There is a better solution to work on iframe base canvas app. Check the following tutorial http://www.phpfour.com/blog/2010/05/quick-start-on-new-facebook-php-sdk-iframe-based/#content

Mahmud Ahsan