Facebook application - server not responding

After the FBML problems I switched to iFrame apps. All well for now except that 2 things:

1) if I did not entered in the app for a few hours and I try to enter, sometimes it gives me the error page that my server did not responded. It shows the Faceboob page with iFrame inside showing the error. After 1 or 2 refreshes it's working fine.

2) I implemented the new SDK with login like this

$facebook = new Facebook(array(
  'appId'  => $fbID,
  'secret' => $fbSecret,
  'cookie' => true,

$user = $facebook->getUser();

$loginUrl = $facebook->getLoginUrl();   

if ($user) {
  try {
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    $user = null;

if (!$user) {
    echo "<script type='text/javascript'>
                 top.location.href = '$loginUrl';

The problem is my first redirect, when user enters for the first time. It redirects to my server URL not my Facebook app URL. If I try to put it like this:

$loginUrl = $facebook->getLoginUrl(
        'redirect_uri' => 'http://apps.facebook.com/xxx/'

the login is entering in an infinite loop.

Any help solving this two problems is welcome:-)



Darko4spain when the user is redirected back to your site, you can detect if is in iframe with javascript and send them back. I have same issue with my app. This is not a pretty fix but it works.

if (window!=window.top) { 
setTimeout("FB.Canvas.setAutoGrow()", 1400);
}else {
top.location.href = 'https://apps.facebook.com/AnotherFeed/?ref=redirect#comments';

example: https://anotherfeed.com/plugins/index.php will redirect you back to my canvas if you are not in the canvas.

Need Your Help

How do I build gevent in python under cygwin?

python cygwin pip gevent libevent

I want to use python consistently in a variety of environments. One of those environments is cygwin. One of the components I want to use is gevent (http://www.gevent.org/intro.html). Under cygwi...

How to expose services in Rest?

java rest restful-url restful-architecture

Please help me to understand how to expose service in REST.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.