Graph API Version

/{group-id}/photos

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

Reading

This operation is not supported.

Publishing

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 /v2.11/{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 /v2.11/{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
}];

Permissions

For public Groups:

  • Any Group member's User access token with the publish_actions permission.

For closed and secret Groups:

  • Any Group admin's User access token with the publish_actions and user_managed_groups permissions.

Fields

NameDescriptionType

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

message

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

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.

NameDescriptionType

id

The newly created photo ID

string

Deleting

This operation is not supported but you can delete a photo using the /{photo-id} node.

Updating

This operation is not supported.