Graph API Version

/{app-id}/roles

The developer roles defined for a Facebook app.

Reading

Graph API Explorer
GET /v2.10/{app-id}/roles HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'GET',
  '/{app-id}/roles'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{app-id}/roles",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{app-id}/roles"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

Permissions

  • An app access token for the app is required.

Fields

NameDescriptionType

app_id

The ID of the app being requested.

string

user

The ID of the user who has a role in the app.

string

role

The name of the role that this person has.

enum{'administrators', 'developers', 'testers', 'insights users'}

Publishing

You can publish to add a user to a role:

POST /v2.10/{app-id}/roles HTTP/1.1
Host: graph.facebook.com

user=123456789&role=administrators
/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'POST',
  '/{app-id}/roles',
  array (
    'user' => '123456789',
    'role' => 'administrators',
  )
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
Bundle params = new Bundle();
params.putString("user", "123456789");
params.putString("role", "administrators");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{app-id}/roles",
    params,
    HttpMethod.POST,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
NSDictionary *params = @{
  @"user": @"123456789",
  @"role": @"administrators",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{app-id}/roles"
                                      parameters:params
                                      HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

Permissions

  • A user access token for any admin of the app is required.

Fields

NameDescriptionType

user

The ID of the user to give a role in the app.

string

role

The name of the role that this person will have.

enum{'administrators', 'developers', 'testers', 'insights users'}

Response

If successful:

{
  "success": true
}

Otherwise a relevant error message will be returned.

Deleting

You can remove a user from a role using this edge:

DELETE /v2.10/{app-id}/roles HTTP/1.1
Host: graph.facebook.com

user=123456789
/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'DELETE',
  '/{app-id}/roles',
  array (
    'user' => '123456789',
  )
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
Bundle params = new Bundle();
params.putString("user", "123456789");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{app-id}/roles",
    params,
    HttpMethod.DELETE,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
NSDictionary *params = @{
  @"user": @"123456789",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{app-id}/roles"
                                      parameters:params
                                      HTTPMethod:@"DELETE"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

Permissions

  • A user access token for any admin of the app is required.

Fields

NameDescriptionType

user

The ID of the user to remove from a role in the app.

string

Response

If successful:

{
  "success": true
}

Otherwise a relevant error message will be returned.