Admin.setRestrictionInfo

From Facebook Developer Wiki

Revision as of 00:04, 27 October 2009 by Pete Bratach (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Contents

Description

Sets the demographic restrictions for the application. This call lets you restrict users at the application level. If you want to restrict only a portion of your application's content, use the fb:restricted-to tag instead.

If the user doesn't match the age and location requirements, then the user cannot see the application at all. If the user's age is hidden for privacy reasons, Facebook still determines whether or not the application is visible to the user.

You should make this call only as needed, when you need to set demographic restrictions. If the restrictions don't change, you don't need to make this call.

Parameters

RequiredNameTypeDescription
required api_key string The application key associated with the calling application. If you specify the API key in your client, you don't need to pass it with every call.
sig string An MD5 hash of the current request and your secret key, as described in the How Facebook Authenticates Your Application. Facebook computes the signature for you automatically.
v string This must be set to 1.0 to use this version of the API. If you specify the version in your client, you don't need to pass it with every call.
optional format string The desired response format, which can be either XML or JSON. (Default value is XML.)
callback string Name of a function to call. This is primarily to enable cross-domain JavaScript requests using the <script> tag, also known as JSONP, and works with both the XML and JSON formats. The function will be called with the response passed as the parameter.
restriction_str string A JSON-encoded string of the restricting attributes. Restrictions include age, location, age_distribution, and type. If you use the Facebook PHP client library, you can actually pass an associative array and Facebook automatically handles the JSON encoding. For example: {"age_distribution":"{\"CA,US\":\"16-25\",\"IN\":\"15-20,30+\"}"}.

When specifying the age or age_distribution, 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.

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.

Specifying a type allows you to target users based on age and location for custom made categories like alcohol (currently the only type available). 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.

Example Requests

In these examples, the info array gets JSON-encoded upon successful execution of the call.

$info=array('age' => '21+', 'location'=>'us'); $success = $facebook->api_client->admin_setRestrictionInfo($info);


$info=array('age_distribution' => {"\"CA,US\":\"16-25\",\"IN\":\"15-20,30+\"}); $success = $facebook->api_client->admin_setRestrictionInfo($info);


$info=array('location' => 'US', 'type' => 'alcohol'); $success = $facebook->api_client->admin_setRestrictionInfo($info);

Response

This method returns true if the restrictions are successfully set.

reference