Graph API Version

Attachments /{post-id}/attachments

Media content associated with a story or comment. Story attachments are accessed from the following endpoints:

  • /{post-id}/attachments displays all attachments and sub attachments associated with a particular post.
  • /{comment-id}?fields=attachment displays any media attachment associated with a comment.

Reading

Graph API Explorer
GET /v2.12/{post-id}/attachments 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(
    '/{post-id}/attachments',
    '{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 */
FB.api(
    "/{post-id}/attachments",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{post-id}/attachments",
    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:@"/{post-id}/attachments"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

Permissions

  • Any valid access token able to view the source content is sufficient to view their attachments

Fields

Name Description Type

description

Text accompanying the attachment

string

description_tags

Profiles tagged in the text accompanying the attachment

Profile[]

Vector

Vector

Vector

Vector

Vector

title

Title of the attachment

string

type

Type of the attachment

string

url

URL of the attachment

string

Publishing

Story attachments are published by including media data on the content the attachment is associated with. This can be done by providing an attachment_id or attachment_url param when publishing comments using the /comments edge or an similar param when publishing posts using any of the /feed edges off of /{post-id}.

Deleting

An app can delete a story attachment if the content it is associated with is deleted.

Updating

You can't update an attachment using the Graph API.

Edges

Name Description

/subattachments

List of subattachments that are associated with this attachment. This will have data if the parent attachment is a container for multiple other attachments. For example, a multi-photo story will have a parent attachment representing an upload of multiple photos to an album where each subattachment will contain the actual photos that were uploaded.