Getting and Setting Application Properties

Problem

I need to retrieve or set some of the properties about my application.

Solution

Use the Admin.getAppProperties() method to retrieve properties:

$targetProps = array('application_name','description');
$properties = $facebook->api_client->admin_getAppProperties($targetProps);

Use the Admin.setAppProperties() method to set properties:

$setProps = array('description' => 'My new description!');
$return = $facebook->api_client->admin_setAppProperties($setProps);

Discussion

Admin.getAppProperties() returns an array, with each named element being one of the properties you requested. In addition to whatever you ask for, Facebook will always return your app’s canvasname, icon_url, and logo_url appended to the end of the returned array.

Admin.setAppPropoerties() will return a code indicating whether it worked. Confusingly, it returns true as the value 1 if it works, which coincides with error code 1, which signifies an unknown error (see Batching Calls). If you’re concerned it’s not working, you can do a check using Admin.getAppPropoerties():

$setProps = array('description' => 'This was set using the new
 Admin.setAppProperties() method!');
$return = $facebook->api_client->admin_setAppProperties($setProps);

$getProps = array('description');
$newDesc = $facebook->api_client->admin_getAppProperties($getProps);

if($newDesc['description'] == $setProps['description']){
    echo 'Success!';
}

Note

These methods are currently marked as beta in the Developers Wiki, ...

Get Facebook Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.