You Are Here: Home » How-To » Programming

How To Show FBML Facebook Friend Invite Form In An IFRAME App?

By Debjit on February 6th, 2011 
Advertisement

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.

FBML based Facebook friend invite form rendered in an iFrame application

FBML based Facebook friend invite form rendered in an 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.

<!DOCTYPE html>
<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:

if (isset($_REQUEST['ids'])){
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.

Advertisement







How To Show FBML Facebook Friend Invite Form In An IFRAME App? was originally published on Digitizor.com on February 6, 2011 - 4:53 pm (Indian Standard Time)