Skip to Main Content
Facebook Cookbook
book

Facebook Cookbook

by Jay Goldman
October 2008
Intermediate to advanced content levelIntermediate to advanced
434 pages
12h 7m
English
O'Reilly Media, Inc.
Content preview from Facebook Cookbook

Invitations and Requests

Problem

I want to give my users the ability to invite their friends to install my app.

Solution

There are a bunch of different ways to handle the actual invitation controls, but they all stem from the use of the fb:request-form tag. The general principle is that you start with an fb:request-form tag and include parameters that define what you want to do, and then you include some combination of fb:multi-friend-selector, fb:multi-friend-input, fb:friend-selector, and fb:request-form-submit. Let’s start with a look at the following example:

<?php
$inviteContent = htmlentities('<fb:name uid="' . $user . '" firstnameonly="true"
 shownetwork="false"/> says this is the most awesomest Super Disco Napping
 application ever made. Come take naps with <fb:pronoun objective="true"
 uid=" ' . $user . '"/>!');
$inviteContent .= htmlentities('<fb:req-choice url="new_napper.php"
 label="Take Naps with Me!" />');
?>

<fb:request-form
    action="index.php"
    method="post"
    invite="true"
    type="Disco Nap"
    content="<?php echo $inviteContent?>">
    <fb:multi-friend-selector actiontext="Tell all your friends! Tell the
 whole bunch!" />
</fb:request-form>

It’s a good idea to put the name of the user sending the invites or requests right into the content so that it has some context for the recipient. The fb:req-choice tag creates a button in the actual invitation that gets sent. You can add more than one button here, with the caveat that they all have different URLs specified in the url parameter; ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning PHP 5.3

Beginning PHP 5.3

Matt Doyle
HTML5 Geolocation

HTML5 Geolocation

Anthony T. Holdener

Publisher Resources

ISBN: 9780596156695Errata