How to Can Post a Multiple Photos via Facebook API

How do I can post a multiple photos via Facebook API

You can make batch requests as mentioned here: https://stackoverflow.com/a/11025457/1343690

But its simple to loop through your images and publish them directly.

foreach($photos as $photo)
{
//publish photo
}


Edit:

(regarding grouping of photos on wall)

This grouping is done by facebook automatically if some photos are uploaded into the same album.

Currently you cannot create an album in a group via Graph API - it is not supported (as of now), see this bug.

But you can do this - create an album manually, then get the album_id by-

\GET /{group-id}/albums, then use the the code with album_id instead of group_id-

foreach($photos as $photo){
$facebook->api("/{album-id}/photos", "POST", array(
'access_token=' => $access_token,
'name' => 'This is a test message',
'url' => $photo
)
);
}

I've tested it, see the result-

Sample Image

Facebook graph api page post with multiple photos

TL;DR

Add publish_to_groups permission to the access token and the request for the post should be with parameter published: true. It appears to have a bug in the graph api or lack of information in the official docs.

Details:

Currently in order to publish a page post with multiple photos you will need to:

  • upload individually the photos and obtain their IDs
  • use PAGE access token which contains publish_to_groups permission
  • attach all photo IDs with attached_media[0..N]: {"media_fbid": "PHOTO_ID"}
  • currently the request for publishing the post fails if it's with parameter published: false, so it needs to be published: true

All of this does not make really sense to me, so I opened a bug report in the developers platform of Facebook. It does not looks right during development of the App to publish live posts to the page...

I'll edit the answer once I have a feedback.

Create multi-photo post on Facebook page using Graph API 7.0 or newer

It is impossible to create a new album via Graph API as of v7.0+. What can be done instead, is to upload multiple pictures to the page in unpublished state using POST /page-id/photos and then creating a feed story with the unpublished pictures as attachments, using POST /page-id/feed. This workflow, with examples, is explained in detail here: https://developers.facebook.com/docs/graph-api/photo-uploads/

Facebook Graph API publish post with multiple attachments

As of now it is not possible to publish one post with multiple pictures. You need to create separate posts for each one of them, or put all the images together in one with your favourite server language and post it as single picture.



Related Topics



Leave a reply



Submit