How To Show FBML Facebook Friend Invite Form In An IFRAME App?
If you are a Facebook developer then you cannot sideline the importance of the Facebook Friend Invite form that run's on Facebook's own markup language FBML. The friend Invite form is one of the best ways to make your application go viral and let users share your application with their friends. In this article we will tell you how to show or render the Facebook Friend Invite form (FBML) in your iFrame application.
Here is the detailed code snippet that enables the use of FBML in iFrame applications (XFBML) and then the other part of the code snippet renders the Facebook friend invite form in your Facebook iFrame app.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<body>
<div id="fb-root"></div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
FB.init({
appId : 'YOUR_FACEBOOK_APP_ID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>
<br /><br />
<fb:serverFbml style="width: 500px;">
<script type="text/fbml">
<fb:fbml>
<fb:request-form
action="invite.php"
target="_top"
method="POST"
invite="true"
type="Test Invite Form"
content="<fb:req-choice url='YOUR_URL' label='Accept' />"
>
<fb:multi-friend-selector
showborder="false"
actiontext="This is a demo invite form">
</fb:request-form>
</fb:fbml>
</script>
</fb:serverFbml>
</body>
</html>
--
In the code snippet above you can see on the 20th line that there is a mention about a script called invite.php. Now, in case you want to store the Facebook IDs of the users who have been invited by any particular user then you can get this value by adding this code snippet to a news invite.php file:
echo "Invitation Successfully Sent";
echo '<pre>';
print_r($_REQUEST['ids']); //store these as you wish
echo '</pre>';
}
--
If you are facing any problem with the implementation do write to me at: [email protected]. You can also hire me for developing Facebook applications for you.