开发者

facebook permission dialog php-sdk shaded inside iframe application

I'am having trouble with facebook php-sdk 开发者_开发问答new api, permission window. I am using facebook connect inside the facebook iframe application.

e-profpy app @ Facebook

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 ? I am using only php no javascript facebook api.

Thanks


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)


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜