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

Granting Permissions to Other Applications Via the Permissions API

Problem

I’m building a whole family of applications, and I’m writing an additional one for myself that is going to aggregate all of the daily metrics and allocations from its siblings into one convenient place. How can I have one app gather stats for another?

(How’s that for a contrived example? There aren’t many times when you’ll need these calls otherwise, but maybe you have more imagination than I do.)

Solution

The Permissions API, which was still in beta at the time of this writing, enables you to grant and revoke permissions for one app to call three Admin methods on behalf of another app. The three available methods are:

You’ll need to know the API key of the application you’re granting permissions to. You can grant on the Admin namespace in general if you want to give permission to call any of the methods:

$permissions = array('admin.');
$result = $facebook->api_client->permissions_grantApiAccess
('456eaf416a25820f18568b7cb0848c3c', $permissions);

That would grant permission for my Super Disco Napping app to have access to your stuff, which I highly recommend you do so that I can sneak peaks at what’s going on. If you decided you wanted to limit me to getting just allocations and metrics, you could modify the call to narrow the permissions:

$permissions = ...

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