O'Reilly logo

Facebook Cookbook by Jay Goldman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required