Facebook Iframe application issues
Here are the problems that I have faced while developing my first iframe application.The problems are very silly but i have to waste so much times to solve the issues. So i want to share some of issues that i faced.
1. POST Submission problem :
http://forum.developers.facebook.com/viewtopic.php?id=24430
While I submit the post data unfortunately I do not get any post data. I have found that post field is empty. I am very surprised how my $_POST field is empty though it submit the action page. I have given a sample form of my application.
Posting it via the server url:
<form action="http://myserver.com/appname" method="POST"> <input type="text" name="test1"></input> <input type="submit" name="Submit"/> </form>
But when I submit this , I cannot get the post data . So I tried by
Posting it via the app callback url:
<form action="http://app.facebook.com/appname" method="POST"> <input type="text" name="test1"></input> <input type="submit" name="Submit"/> </form>
After search in facebook developer wiki,forum and blog , I have known that
while submit the form , iframe lost the session key as there is no session key passed . As a result it lost user id and lost all the post data. That’s why i have to set user_id. So below is the forum post link :
http://forum.developers.facebook.com/viewtopic.php?id=22929
And here Is how I solve this issue . This my modified form where I added two hidden fields. One is fb_sig_session_key and another one is user_id.
After search in facebook developer wiki,forum and blog , I have known that
while submit the form , iframe lost the session key as there is no session key passed . As a result it lost user id and lost all the post data. That’s why i have to set user_id. So below is the forum post link :
http://forum.developers.facebook.com/viewtopic.php?id=22929
And here Is how I solve this issue . This my modified form where I added two hidden fields. One is fb_sig_session_key and another one is user_id.
Posting via fb_sig_session_key and user_id
<form action="http://myserver.com/appname" method="POST"> <input type="text" name="test1"></input> <input type="hidden" name="fb_sig_session_key" value=”<?php $_GET[‘fb_sig_session_key’]”></input> <input type="hidden" name="user_id" value=”<?php $_GET[‘user_id’]”></input> <input type="submit" name="Submit"/> </form>
So after submit the form here I show how can I set_user and now find the post values.
<?php
if (isset ( $_REQUEST ['kb_fb_sig_session_key'] )) {
$this->fb_sig_session_key = $_REQUEST ['fb_sig_session_key'];
}
if (isset ( $_REQUEST ['user_id'] )) {
$this->uid = $_REQUEST ['user_id'];
}
if ($this->uid != '') {
$this->facebook->set_user ($this->uid, $this->kb_fb_sig_session_key );
}
$this->facebook->set_user ($this->uid, $this->fb_sig_session_key );
?>
2. Application Link problem :
While I click on any link in my iframe application , I have found that it reloads the whole facebook page again in the iframe canvas. I just use this type of code and found the problem load .
<a href=”http://apps.facebook.com/MyApp/invite.php”>Invite</a>
I found the solution in this thread : http://forum.developers.facebook.com/viewtopic.php?pid=208220
Only add the taget=”__top” into the anchor.
So I add target=”_top”. <a href=”http://apps.facebook.com/MyApp/invite.php”>Invite</a>. And now it work.
3. iframe size problem :
I have faced problem to resize my frame application. Initially when page load the frame size is correct. But when I show the facebook profile photo of users , then find that it does not resize. I do not see the footer and it cut down. We have solve this problem by adding javascript setTimer to resize the height. You have seen similar type problem here : http://forum.developers.facebook.com/viewtopic.php?pid=17541#p17541
4. setting issues :
I think to set up my application as an iframe application, I do not need to set up the connect url. But when I do not set up connect url I see blank page. So when I set up the call back url , I have found that my application working.






