Graph API Version

Group Photos

This edge allows you to publish a photo to a Group's feed.

Use of this endpoint requires App Review. Apps that have already been approved to access this endpoint have until August 1, 2018, to resubmit for review or lose endpoint access.

Reading

This operation is not supported.

Creating

You can publish photos via upload or URL.

Via Upload

Capture a photo via file upload as multipart/form-data then use the source parameter:

POST /v3.1/{group-id}/photos HTTP/1.1
Host: graph.facebook.com

source=%7Bimage-data%7D
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->post(
    '/{group-id}/photos',
    array (
      'source' => '{image-data}',
    ),
    '{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(
    "/{group-id}/photos",
    "POST",
    {
        "source": "{image-data}"
    },
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
Bundle params = new Bundle();
params.putString("source", "{image-data}");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{group-id}/photos",
    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 = @{
  @"source": @"{image-data}",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{group-id}/photos"
                                      parameters:params
                                      HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

Via URL

Publish a photo from the internet by using its URL and the url parameter:

POST /v3.1/{group-id}/photos HTTP/1.1
Host: graph.facebook.com

url=%7Bimage-url%7D
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->post(
    '/{group-id}/photos',
    array (
      'url' => '{image-url}',
    ),
    '{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(
    "/{group-id}/photos",
    "POST",
    {
        "url": "{image-url}"
    },
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
Bundle params = new Bundle();
params.putString("url", "{image-url}");
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{group-id}/photos",
    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 = @{
  @"url": @"{image-url}",
};
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{group-id}/photos"
                                      parameters:params
                                      HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];

Requirements

Type of RequirementDescription

App Review

Your app must be approved for the following login permissions and features: (Click to expand)

Login permissions

publish_to_groups

Features

Groups API

App Installation

The app must be installed on the Group.

Tokens

A User access token for a user who is a member of the Group where the app is installed.

Permissions

The user must grant your app this permission:

publish_to_groups

Fields

Name Description Type

caption

The description of the photo, used as the accompanying status message in any feed story.

string

message

The description of the photo.

string

published

Set to false if you don't want the photo to be published immediately. Default value: true.

string

source

The photo, encoded as form data. Either this or url field is required, but both should not be used together.

multipart/form-data

url

The URL of a photo that is already uploaded to the internet. Either this or source is required, but both should not be used together.

string

Response

If successful, you will receive a response with the following information. In addition, this endpoint supports read-after-write and can immediately read the node represented by id in the return type.

Name Description Type

id

The newly created photo ID

string

Updating

This operation is not supported.

Deleting

This operation is not supported.