tags:

views:

1062

answers:

5

i am using iframe to render my app from my server. the problem is once i click on a link in my app, i am being redirected to my server. i mean, i remain in tha canvas page for a second, then suddenly instead of viewing it in an iframe on the facebook website, i am redirected the app URL on my server. I am using PHP and MySQL.

why is this happening.

the firebug info: this is the POST info that firebug is giving. due to the above problem it is also not POSTing to the DB.

<html>
<body>

<script type="text/javascript">
top.location.href = "http://www.facebook.com/login.php?v=1.0&amp;api_key="xxxxx"&amp;next=http%3A%2F%2F&lt;my-web-server.com&gt;%2F&lt;appfolder&gt;%2Fuser_submit.php";
</script>

EDIT
apparently, it is running fine in Chrome for Mac.


EDIT 2
what i just found out by [Stopping] the browser on the facebook page through Firebug: only this part of the app is being loaded on the Facebook page. the rest of the app gets loaded after it redirects it to my server.

<body>
<div id="wrap-iframe">

<script type="text/javascript">
top.location.href = "http://www.facebook.com/login.php?v=1.0&amp;api_key="xxxxx"&amp;next=http%3A%2F%2Fmy-domain-server.com%2Fapplocation%2Fuser.php";
</script></div></body>

EDIT 3
I did some tinkering and apparently, it has angered it even further. now even the first page redirects me. If only I remembered what I did...:-(

Warning: Cannot modify header information - headers already sent by (output started at /home/amitver/public_html/roadies/user.php:7) in /home/amitver/public_html/roadies/facebook.php on line 257

Warning: Cannot modify header information - headers already sent by (output started at /home/amitver/public_html/roadies/user.php:7) in /home/amitver/public_html/roadies/facebook.php on line 257

Warning: Cannot modify header information - headers already sent by (output started at /home/amitver/public_html/roadies/user.php:7) in /home/amitver/public_html/roadies/facebook.php on line 257

Warning: Cannot modify header information - headers already sent by (output started at /home/amitver/public_html/roadies/user.php:7) in /home/amitver/public_html/roadies/facebook.php on line 261
A: 

I had this problem awhile back. Two things to try:

  1. Make sure there are no characters / whitespace before your opening <?php tag (it should be first in the file)
  2. Do you call require_frame() ?
Eric
what is require_frame?
amit
require_frame is a facebook api function that tells facebook whether to display your page in its frame or just your page
Eric
A: 

try putting this code on top of your page:

ob_start();

This should solve the problem of 'headers already sent' error at least.

Sarfraz
A: 

There is a known reason for this but it takes some investigation to find. IIRC, what happens is that when someone changes pages inside your iframe, you are making another require_login call. the FB client tries to use available data to authenticate - post / get / cookies - but if it fails it will redirect to an fb login. If the user is already logged in and authorized your app, this will instantly (invisibly) redirect back to your app, but there is a bug on facebook's end (I think) that causes it to redirect to your callback url instead of your canvas url, hence popping out of frame.

Solution: pass the fb_ get params in your query string along to every page. Basically take everything starting with "fb_" in the url and tack it on to all of your links. This gives the api client something else to validate with.

Tesserex
+1  A: 

try this link.... you will definitely get the solution :D

http://www.foobots.net/breakouts.html

enjoy

RSTanvir
thanks a lot. this was really helpful. except i couldnt get option $4 to work. i am confused about the $parms part. can you help?
amit
hey amit, sorry for late reply :)the $parms part is simply a url parameter, which you need to append with your every page link. hope this help :)
RSTanvir
A: 

http://www.facebook.com/login.php?v=1.0&amp;api_key="xxxxx"&amp;next=http://someurl.com/user.php&amp;canvas=1";

adding canvas=1 seems to do the trick. Keeps it within the canvas and doesn't open the callback url.

gnosio