Fb:restricted-to

From Facebook Developer Wiki

Jump to: navigation, search

Description

Lets you tailor the enclosed content to display to specific ages, locations, or content types.

You should use this tag with fb:else so you can provide alternate content in case the viewing user doesn't meet the demographic requirements. Also, if the user hides their age for privacy reasons, Facebook cannot determine whether or not the content is visible to the user, and thus it cannot be displayed. In this case, your fb:else clause should contain content that any user who doesn't necessarily meet these restrictions could see.

Note: You cannot use the fb:restricted-to tag to send invitations and requests to a demographically-restricted set of users, as with fb:multi-friend-selector. Instead, use the admin.getRestrictionInfo and admin.setRestrictionInfo API calls to target those users for your application overall.

Note: If you want to restrict your entire application to a given set of demographic restrictions, use admin.setRestrictionInfo.


Attributes

RequiredNameTypeDescription
optional age string The valid age or age range that can see the content. To specify multiple age ranges, separate each entry with a comma. Every specified age must be an integer. You can use plus (+) and minus (-) to restrict content to that age or older/younger (like 21+ for 21 and older or 18- for younger than 19). You can also specify a range of ages, like 18-35 so anyone between the ages of 18 and 35 (inclusive) can see the content. You can also specify multiple age ranges (like 19-,30+ -- if you want to exclude people in their 20s, for example). Every specified age must be an integer, and only the integer part of a user's age is taken into account. So for example, a user who is 17.9 years old will be treated as 17, and "18-35" includes anyone 18 or older but under 36.
location string The country or countries that can see the content. To specify multiple countries, separate each entry with a comma. When specifying the location, specify the country or countries (using a comma-separated list) from the ISO 3166 alpha 2 code list. This list is not necessarily the same as the IANA ccTLD (country code top level domain) list. For example, the ISO 3166 entry for England is .gb, while the IANA entry is .uk.
age_distribution array An array containing age and location restrictions for multiple areas.
type string The type of content being filtered. You can specify alcohol at this time. Before rendering your FBML, we run a check against the type on Facebook, and if the user meets the age and location requirements, we'll render the content.


Examples

Restricting content to users 17 and younger only.

<fb:restricted-to age="17-">Let's talk boy bands. <fb:else>Cool, the kids are gone!</fb:else> </fb:restricted-to>


Restricting content to users 18 and older in Great Britain only.

<fb:restricted-to age="18+" location="gb">Remember to drive on the <i>correct</i> side of the road. <fb:else>You're either not from Great Britain or you're from Great Britain but not 18 yet.</fb:else> </fb:restricted-to>


Specifying alcohol content to users in the United States only.

<fb:restricted-to location="us" type="alcohol">Enjoy a fine malt beverage. <fb:else>Enjoy a nice soft drink.</fb:else> </fb:restricted-to>
reference