How do I can post a multiple photos via Facebook API

Red October picture Red October · Apr 11, 2014 · Viewed 16.3k times · Source

Now I posting a single photo to wall like this:

$response = $facebook->api("/$group_id/photos", "POST", array(
    'access_token=' => $access_token,
    'message' => 'This is a test message',
    'url' => 'http://d24w6bsrhbeh9d.cloudfront.net/photo/agydwb6_460s.jpg',
   )
);

It works fine, but can I somehow post a multiple photos, something like this:

enter image description here

Thanks in advance!

Answer

Kcoder picture Kcoder · Aug 24, 2016

You can now publish multiple images in a single post to your feed or page:

For each photo in the story, upload it unpublished using the {user-id}/photos endpoint with the argument published=false.

You'll get an ID for each photo you upload like this:

{
  "id": "10153677042736789"
}

Publish a multi-photo story using the {user-id}/feed endpoint and using the ids returned by uploading a photo

 $response = $facebook->api("/me/feed", 'POST',
  array(
    'access_token=' => $access_token,
    'message' => 'Testing multi-photo post!',
    'attached_media[0]' => '{"media_fbid":"1002088839996"}',
    'attached_media[1]' => '{"media_fbid":"1002088840149"}'
  )
);

Source: Publishing a multi-photo story