Facebook Cookbook - Jay Goldman [84]
border_color
string
#8496ba
The color of the border.
include_me
bool
false
Setting this to true will allow people to add themselves to the field.
max
int
20
Limits the number of friends who can be added.
exclude_ids
array
N/A
Comma-separated list of IDs to exclude from the field.
prefill_ids
array
N/A
Comma-separated list of IDs to automatically pre-fill into the field.
prefill_locked
bool
false
Setting this to true will lock the list of pre-filled IDs (if you included one), preventing users from deleting them. This will have no effect without a prefill_ids list.
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:
$inviteContent = htmlentities(' application ever made. Come take naps with $inviteContent .= htmlentities(' ?> method="post" invite="true" type="Disco Nap" content=""> 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; otherwise, only the last of that group will appear. According to the Platform Wiki, it’s important to encode the content that you want to have in the invitation so that things like < become < and © becomes ©, which the PHP htmlentities function will handle for you. See the Discussion in this recipe for a full breakdown of the parameters. If you’re awarding any kind of points or want to track who has been sending invites, you could also append the ID of the sender to the URL in the fb:req-choice tag(s) and then include some code on that page to log them to your database: $inviteContent .= htmlentities(' On to the contents of the fb:request-form. Facebook has given you a lot of flexibility here, though there are few occasions when you’ll need to take advantage of it. In this case, we’ve put in an fb:multi-friend-selector, which will give us essentially the full-page version of the control with our actiontext listed across the top. If you’re doing an invite type of page, this is what you want to use: it’s big and commanding and gives lots of space for people to select their friends. As mentioned earlier, you can also use any combination of fb:multi-friend-selector, fb:multi-friend-input, fb:friend-selector, and fb:request-form-submit, although combining them can result in a pretty strange form. The other options are covered in the Discussion. Discussion Table 6-18. Parameters for fb:request-form Name Type Default value Description type string N/A The type of invitation will appear on the recipient’s Notifications page and in the title of the invitation itself (e.g., “You have received a Disco Nap invitation”). This is required. content string N/A The content to put in the invitation itself. This should be encoded for HTML entities
The parameters for fb:request-form are listed in Table 6-18.