Graph API Version

Graph API Reference /{app-id}/achievements

The list of Games achievement types that have been registered by this app.

Reading

Graph API Explorer
GET /v2.11/{app-id}/achievements HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '/{app-id}/achievements',
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{app-id}/achievements",
    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}/achievements"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

Permissions

  • An app or user access token is required to view achievement types for this app.

Fields

An array of Achievement Type objects.

Publishing

You can publish to this edge to create an achievement type for this app:

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

achievement=http%3A%2F%2Fexample.com%2Fachievement%2F
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->post(
    '/{app-id}/achievements',
    array (
      'achievement' => 'http://example.com/achievement/',
    ),
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
Bundle params = new Bundle();
params.putString("achievement", "http://example.com/achievement/");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{app-id}/achievements",
    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 = @{
  @"achievement": @"http://example.com/achievement/",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{app-id}/achievements"
                                      parameters:params
                                      HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

Permissions

  • An app access token is required to create new achievement types for that app.

Fields

NameDescriptionType

achievement

The URL of an Open Graph Achievement object. This URL should contain the tags necessary to describe an Achievement object. This field is required.

string

display_order

Order of the achievement when shown in any achievement stories UI. A display order of 100 is displayed in the UI before 200. Values should be unique and incremented in the correct order for your achievements.

int

Response

If successful:

{
  "success": true
}

Otherwise a relevant error message will be returned.

Deleting

You can delete using edge to remove an achievement type from this app:

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

achievement=http%3A%2F%2Fexample.com%2Fachievement%2F
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->delete(
    '/{app-id}/achievements',
    array (
      'achievement' => 'http://example.com/achievement/',
    ),
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
Bundle params = new Bundle();
params.putString("achievement", "http://example.com/achievement/");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{app-id}/achievements",
    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 = @{
  @"achievement": @"http://example.com/achievement/",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{app-id}/achievements"
                                      parameters:params
                                      HTTPMethod:@"DELETE"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

Permissions

  • An app access token is required to remove achievement types for that app.

Fields

NameDescriptionType

achievement

The URL of an Open Graph Achievement object. This field is required.

string

Response

If successful:

{
  "success": true
}

Otherwise a relevant error message will be returned.

When you delete an achievement:

  • The app will no longer be able to publish that achievement.
  • The point value of the achievement is deducted from the app’s achievements point total.
  • All existing achievement instances for that type will not show up in any UI though they will still be available via the API.

Updating

You should update existing achievement types by updating the meta tags on the achievement's URL, and then forcing a re-scrape.