title: Facebook require_login() in iFrame App
body: <p>I have serious problem with iframe application. I need to use many external JS libraries and other dynamic stuuf so FMBL application can't be done. When I call require_login() I get applicaition installing dialog when app is not already installed, which is ok. But then after authorization application enters an endless redirect loop with parameters like auth_token, installed and so. Yesterday I managed to fix this, but today it's broken again... What the heck is happening with FB? It's driving me crazy to find a sollution, none of ones found on net doesn't seem to be working.</p>
  
  <p>So far I tried:</p>
  
  <p><a href="http://abhirama.wordpress.com/2010/03/07/facebook-iframe-xfbml-app/" rel="nofollow noreferrer">http://abhirama.wordpress.com/2010/03/07/facebook-iframe-xfbml-app/</a> (7th march 2010!)
  <a href="http://forum.developers.facebook.com/viewtopic.php?pid=156092" rel="nofollow noreferrer">http://forum.developers.facebook.com/viewtopic.php?pid=156092</a>
  <a href="http://www.keywordintellect.com/facebook-development/how-to-set-up-a-facebook-iframe-application-in-php-in-5-minutes/" rel="nofollow noreferrer">http://www.keywordintellect.com/facebook-development/how-to-set-up-a-facebook-iframe-application-in-php-in-5-minutes/</a></p>
  
  <p><a href="http://www.markdeepwell.com/2010/02/validating-a-facebook-session-within-an-iframe/" rel="nofollow noreferrer">http://www.markdeepwell.com/2010/02/validating-a-facebook-session-within-an-iframe/</a>
  <a href="http://forum.developers.facebook.com/viewtopic.php?pid=210449" rel="nofollow noreferrer">http://forum.developers.facebook.com/viewtopic.php?pid=210449</a>
  <a href="http://www.ajaxlines.com/ajax/stuff/article/facebook_fbml_rendering_in_iframe_application.php" rel="nofollow noreferrer">http://www.ajaxlines.com/ajax/stuff/article/facebook_fbml_rendering_in_iframe_application.php</a>
  <a href="http://www.aratide.com/php/solving-the-break-out-issue-in-iframe-facebook-applications/" rel="nofollow noreferrer">http://www.aratide.com/php/solving-the-break-out-issue-in-iframe-facebook-applications/</a></p>
  
  <p>None of the above worked... According to those and some FB docs:
  <a href="http://wiki.developers.facebook.com/index.php/FB_RequireFeatures" rel="nofollow noreferrer">http://wiki.developers.facebook.com/index.php/FB_RequireFeatures</a>
  <a href="http://wiki.developers.facebook.com/index.php/Cross_Domain_Communication_Channel" rel="nofollow noreferrer">http://wiki.developers.facebook.com/index.php/Cross_Domain_Communication_Channel</a></p>
  
  <p>My example test files look as follow:</p>
  
  <pre><code>&lt;?php
  //Link in library.
  require_once '../application/vendor/Facebook/facebook.php';
  
  //Authentication Keys
  $appapikey = 'XXXX';
  $appsecret = 'XXXX';
  
  //Construct the class
  $facebook = new Facebook($appapikey, $appsecret);
  
  //Require login
  $user_id = $facebook-&gt;require_login();
  
  ?&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"&gt;
  &lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"&gt;&lt;/script&gt;
    This is you: &lt;fb:name uid="&lt;?php echo  $user_id?&gt;"&gt;&lt;/fb:name&gt;
    &lt;?php var_dump($facebook-&gt;$this-&gt;facebook-&gt;api_client-&gt;friends_get())?&gt;
    &lt;script type="text/javascript"&gt;
   FB_RequireFeatures(["XFBML"], function(){
    FB.Facebook.init("&lt;?=$appapikey?&gt;", "xd_receiver.html");
   });
    &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And cross-domain file xd_receiver.html is:</p>
  
  <pre><code>&lt;!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
    &lt;head&gt;
      &lt;title&gt;cross-domain receiver page&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;script src="http://static.ak.facebook.com/js/api_lib/v0.4/XdCommReceiver.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>How do I get it working?</p>
  
  <p>I'm using Kohana framework to do this and already replaced header('Location') with url::redirect() in facebook php library.</p>