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

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

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