From Facebook Developer Wiki
(Redirected from
Invite Page)
Description
Facebook will deprecate this tag in late 2009/early 2010.
After that time, you will be able to send requests and invites through the Inbox. For more information, please read the Developer Roadmap.
Creates a form that sends requests to the selected users. To send requests/invitations to multiple users, create one of these forms and include either an fb:multi-friend-selector or any combination of fb:multi-friend-input, fb:friend-selector and fb:request-form-submit. The form is submitted after the user confirms the sending of the request.
If you want to invite only one friend, without making the user select from a list of friends, use the fb:request-form-submit tag within the fb:request-form tag, and make sure to set the appropriate attributes (uid, label) on the submit button to indicate that you are sending an invite to only one friend.
In general, use fb:multi-friend-selector in a nearly full-page invitation interface where the user is intended to select a large number of people, and fb:friend-selector or fb:multi-friend-input in situations where the user is selecting a smaller number of users and you want to integrate it into the context of your own page. As a middle-ground alternative, you can use the fb:multi-friend-selector (condensed) for places where the user might select a medium-sized list of people without needing a full-page interstitial invitations interface.
For developers using iframes, you can use XFBML and the fb:serverfbml tag to render fb:request-form. In addition, you can send requests using the Multi_friend_selector, or you can use the fb_force_mode parameter to render a particular canvas page with FBML.
For developers wishing to utilize more form parameters, typical form input can be used with the attribute fb_protected="true" within any fb:request-form-submit tag. The fb_protected attribute prevents FBJS from touching secure elements in the form.
Attributes
| Required | Name | Type | Description |
| required | type | string | The type of request or invitation to generate. This corresponds to the word that is displayed on the home page. For example, "event." |
|
|---|
| content | string | The contents of the request or invitation to be sent. It should use FBML formatting that contains only links and the special tag <fb:req-choice url="" label="" /> to specify the buttons to be included in the request. Make sure that you properly encode this attribute. For example, use the PHP "htmlentities" function. |
|
|---|
| optional | invite | bool | Set this to true if you want to send an invitation or false if you want to send a request. The difference between them is in the content that the user sees. (Default value is false.) |
|
|---|
| action | string | The place where a user gets redirected after submitting the form through the fb:request-form-submit button or when they click Skip this Step. By default the user is directed to http://apps.facebook.com/yourapp/null. Note: This default behavior may not be preserved.[verify] |
|
|---|
| method | string | Set it to either GET or POST, as you would with a form. |
|
|---|
POST Variables
| Required | Name | Type | Description |
| typeahead | string | The string containing any content the user typed into the multi-selector box. |
|
|---|
| ids | array | A zero-based array containing all of the user IDs of the people the user invited. |
|
|---|
Examples
Example FBML Invite Page
<fb:fbml>
<fb:request-form
action="index.php"
method="POST"
invite="true"
type="YOUR APP NAME"
content="Your text goes here. <?php echo htmlentities("<fb:req-choice url=\"YOUR CANVAS URL\" label=\"Authorize My Application\"") ?>" >
<fb:multi-friend-selector showborder="false" actiontext="Invite your friends to use YOUR APP NAME.">
</fb:request-form>
</fb:fbml>
Note: The <?php echo htmlentities("<fb:req-choice url=\"YOUR CANVAS URL\" label=\"Authorize My Application\"") ?> is needed to add a button to accept the invite.
Example Java Invite Page
Here is the FBML:
<fb:request-form
action="start.htm"
method="POST"
invite="true"
type="sample network"
content="This network is the best place on Facebook for viewing, sharing and giving
friends the highest quality stuff. Join me on this network!
<fb:req-choice url='http://www.facebook.com/login.php?api_key=<c:out value='${apiKey}' />'
label='Check out this network!' />
">
<fb:multi-friend-selector
showborder="false"
actiontext="Invite your friends to this network."
exclude_ids="<c:out value='${appUserFriends}' />"
max="20" />
</fb:request-form>
Here is the server side Java:
protected Map referenceData(HttpServletRequest request) throws Exception {
logger.info("InviteFriendsFormController.referenceData ...");
FacebookRestClient facebookRestClient = getFacebookUtils().getFacebookRestClient(request);
//get the list of friends who are app users so they can be excluded from the invite page
String appUserFriends = getFacebookUtils().getAppUsersFriendsString(facebookRestClient);
HashMap referenceData = new HashMap();
referenceData.put("appUserFriends", appUserFriends);
referenceData.put("apiKey", PropertyUtils.getInstance().getPropertyValue("API_KEY"));
getFacebookUtils().loadUrlData(referenceData);
return referenceData;
}
Example PHP Invite Page
<?PHP
// Get these from http://developers.facebook.com
$api_key = 'xxx';
$secret = 'xxx';
// Names and links
$app_name = "Application name";
$app_url = "app-url"; // Assumes application is at http://apps.facebook.com/app-url/
$invite_href = "invite.php"; // Rename this as needed
require_once 'facebook.php';
$facebook = new Facebook($api_key, $secret);
$facebook->require_frame();
$user = $facebook->require_login();
if(isset($_POST["ids"])) {
echo "<center>Thank you for inviting ".sizeof($_POST["ids"])." of your friends on <b><a href=\"http://apps.facebook.com/".$app_url."/\">".$app_name."</a></b>.<br><br>\n";
echo "<h2><a href=\"http://apps.facebook.com/".$app_url."/\">Click here to return to ".$app_name."</a>.</h2></center>";
} else {
// Retrieve array of friends who've already authorized the app.
$fql = 'SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1='.$user.') AND is_app_user = 1';
$_friends = $facebook->api_client->fql_query($fql);
// Extract the user ID's returned in the FQL request into a new array.
$friends = array();
if (is_array($_friends) && count($_friends)) {
foreach ($_friends as $friend) {
$friends[] = $friend['uid'];
}
}
// Convert the array of friends into a comma-delimeted string.
$friends = implode(',', $friends);
// Prepare the invitation text that all invited users will receive.
$content =
"<fb:name uid=\"".$user."\" firstnameonly=\"true\" shownetwork=\"false\"/> has started using <a href=\"http://apps.facebook.com/".$app_url."/\">".$app_name."</a> and thought it's so cool even you should try it out!\n".
"<fb:req-choice url=\"".$facebook->get_add_url()."\" label=\"Put ".$app_name." on your profile\"/>";
?>
<fb:request-form
action="<? echo $invite_href; ?>"
method="post"
type="<? echo $app_name; ?>"
content="<? echo htmlentities($content,ENT_COMPAT,'UTF-8'); ?>">
<fb:multi-friend-selector
actiontext="Here are your friends who don't have <? echo $app_name; ?> yet. Invite whoever you want -it's free!"
exclude_ids="<? echo $friends; ?>" />
</fb:request-form>
<?PHP
}
?>

Example Overloaded Form
<fb:fbml>
<fb:request-form method="POST" action="compare.php" content="some content" type="" invite="false">
<input id="first_overloaded_id" type="hidden" fb_protected="true" value="first_overloaded_value" name="first_overloaded_name"/>
<input id="second_overloaded_id" type="hidden" fb_protected="true" value="second_overloaded_value" name="second_overloaded_name"/>
<div class="clearfix" style="padding-bottom: 10px;">
<fb:multi-friend-selector condensed="true" style="width:80%;" />
</div>
<fb:request-form-submit />
</fb:request-form>
</fb:fbml>
Example ASP.NET Invite Page
<p>Invite a friend to use this application...
<fb:request-form method="POST" invite="true"
type="Application Name" content="You have been invited to the Application Name application .
<%= Server.HtmlEncode("<fb:req-choice url=""http://apps.facebook.com/appurl/"" label=""OK"" />") %> " >
<fb:multi-friend-selector showborder="false" actiontext="Invite your friends to use this application." />
<fb:request-form-submit />
</fb:request-form>
</p>
Example Python (Django + PyFacebook) Invite Page
def invite_friends(request):
#HTML escape function for invitation content.
from cgi import escape
facebook_uid = request.facebook.uid
# Convert the array of friends into a comma-delimeted string.
exclude_ids = ",".join([str(a) for a in request.facebook.friends.getAppUsers()])
# Prepare the invitation text that all invited users will receive.
content = """<fb:name uid="%s" firstnameonly="true" shownetwork="false"/>
wants to invite you to play Online board games,
<fb:req-choice url="%s"
label="Put Online Gaming and Video Chat on your profile!"/>
""" % (facebook_uid, request.facebook.get_add_url())
invitation_content = escape(content, True)
return render_to_response('facebook/invite_friends.fbml',
{'content': invitation_content, 'exclude_ids': exclude_ids })
Example Python (Django + PyFacebook) Invite Friends template
<fb:request-form action="http://apps.facebook.com/livevideochat/?skipped=1"
method="POST" invite="true" type="Online Games"
content="{{ content }}">
<fb:multi-friend-selector max="20"
actiontext="Here are your friends who aren't using Online Games and Live Video Chat. Invite them to play Games Online today!"
showborder="true" rows="5" exclude_ids="{{ exclude_ids }}">
</fb:request-form>
Notes
- Make sure to include whatever attributes you would normally include if you were creating a <form> tag, such as
action and method, as mentioned above.
- The fb:multi-friend-selector tag does not show up in Internet Explorer 6.[verify][I have IE 6 and it works fine] - It did work fine for me too, but at least since last code push it doesn't show up. Firefox works. But in IE I' only get a small borderline around I guess one pixel heigth of empty space. Please cross-check!
- IE6 Not working for me either. Works in all other browsers I have tested. Chrome, firefox, ie8, safari work fine. IE6, the frame is only like 200px tall and it forces the user to scroll down to see the rest of the frame.
- The type attribute appears to have a hard limit of 20 characters. Anything else is truncated.
- When sending invitations (
invite="true") users can also choose to invite friends who aren't using Facebook via email. Invitations sent this way do not count towards your allocations, and recipients of those invitations are taken directly through Express Registration to join both Facebook and the application.
- You can not add line breaks or any other formatting to the message (forum)
- You can not add regular <input> fields directly to <fb:request-form> or the form will be post to an invalid page when the user clicks "skip" button (forum).(Correction: This seems to work fine now. Try it)
- If you overload the form with your own input tags, and get "request_form is null" Javascript error, try changing the name attribute of your input tags.