3

Use Case: I want to publish a user generated message with a specific link and a bunch of images clicked by user on Facebook. I can post simple message with a link but not able to post multiple images with that post. As a work around, I can post a single image by making it as a preview image of a link but how can I post multiple images with a FB post ?

Going through official doc, doesn't mention any such scenarios:

https://developers.facebook.com/docs/graph-api/reference/v2.4/page/feed#publish https://developers.facebook.com/docs/graph-api/reference/v2.4/group/feed#publish https://developers.facebook.com/docs/graph-api/reference/v2.4/user/feed#publish

Can anyone give me some pointer to some documentation which explains this task. I'm using Facebook Javascript SDK for all api calls.

Also, if this is not supported then is there any workaround to accomplish it ? I can see multiple social media managements softwares like Hootsuites has this functionality. I assume there must be some way to accomplish my tasks. Any pointers will be appreciated.

Updates: Based on the answer, I found following apis which allow you to create an album. https://developers.facebook.com/docs/graph-api/reference/v2.4/group/albums https://developers.facebook.com/docs/graph-api/reference/page/albums#Creating https://developers.facebook.com/docs/graph-api/reference/user/albums#Creating https://developers.facebook.com/docs/graph-api/reference/v2.4/album#publish

Few quick doubts:

  • what is id (The Object ID that we're creating an album for) in user,page and group album api ?
  • Once we have created album, how do we add photos in those created albums ?
  • Can I use this https://developers.facebook.com/docs/graph-api/reference/v2.4/album/photos#publish for adding photos to albums created in previous step ?
  • Also, How can I use this album to publish in a user,page and group feed ? There is no param for album in feed api ? Refer to my updated title for better understanding of my intentions. Look at this
  • Also, to give more clarity of my task, I can post one picture in the above api call by using it as a link preview image. Issue comes when there is a link with a given message to be published on user/group/page feed and there a bunch of images which needs to be attached to this post. How can I accomplish this ?
  • If above point is not feasible, then let me know if following approach works or not ? Use this to create an album with a given message. Add links to message only for publishing on facebook. One DownSide will be this new album won't appear in feed. But this way we can publish a feed with multiple images and links. Let me know of your thoughts on this.
  • By taking approach mentioned above, there will be no need of using this. Also, albums created will be show on feed, right ?

It'll be great if I can get answer to questions mentioned above.

dark_shadow
  • 3,503
  • 11
  • 56
  • 81

2 Answers2

7

As of now, it is not possible to post multiple photos at once. This is subject of many threads already, one of them mentioned using an album, adding photos to it and publishing it to the feed:

Update: There is another way now, by uploading photos with the "published=false" flag. It is explained in detail in the docs:https://developers.facebook.com/docs/graph-api/photo-uploads#upload

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • Also, is there any limit on the image/album size which can be published on fb ? And what types of image formats are supported on FB ? – dark_shadow Aug 25 '15 at 04:19
  • image formats: i guess the usual ones (jpg, gif, png), but that should be very easy to find out. just try uploading one of those three on facebook.com. – andyrandy Aug 25 '15 at 07:11
  • The threads which you have mentioned uses ios sdk but in my case I'm using JS SDK. Do you think that will make any difference ? – dark_shadow Aug 25 '15 at 18:50
  • Can you please take a look at my updated question title and updated content. I really appreciate your help if you can answer above questions – dark_shadow Aug 26 '15 at 19:46
  • that is WAY too broad, and it´s not a good idea to change the question to something completely different. if you got a new question, create a new thread. most questions of yours can just be answered by taking a quick look at the api reference anyway. – andyrandy Aug 26 '15 at 19:54
  • to make this perfectly clear: stackoverflow is a place to ask specific questions, not "how do i do xy?" without any information on what you have tried so far. use the docs, test stuff, debug stuff...that is what developers do ;) – andyrandy Aug 26 '15 at 19:56
6

Facebook recently added the ability to publish multiple images in a single post to your feed or page without having to use albums as a workaround.

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 using the attached_media argument multiple types with a value in this format:

{"media_fbid":"1218662968186209"}

Source: Publishing a multi-photo story

Kcoder
  • 3,422
  • 4
  • 37
  • 56
  • I followed the documentation by Facebook, but the captions of images are omitted when `published` is set to `false`. Do you guys experience the same? – Egist Li Jan 10 '17 at 01:21
  • I did not, but it was 5 months ago. The captions remained on the individual pictures and the combined-image wall post itself had its own text too. You may want to report this regression to Facebook if someone hasn't already: https://developers.facebook.com/bugs/ – Kcoder Jan 10 '17 at 17:20
  • 1
    Thanks for your reply, I just found the reason that caption is stripped is because I use `image` as the filed name for the file to upload (The upload succeeds with that though). I change the field to `source` then it works as expected. – Egist Li Jan 10 '17 at 19:39
  • Facebook official documentation (https://developers.facebook.com/docs/graph-api/photo-uploads#upload) clearly mentions that it is not possible (to date) for pages to publish multiple images with a textual post. From my own experience, you can post multiple images but they all will appear as separate posts, beating the requirement. Anyone has a solution to this? – Sayed Apr 10 '17 at 06:09
  • Thanks. I was uploading photos via `/group-id/albums` but there is no way to create a post associated with 1 album. As you mentioned, it's necessary to upload unpublished photos and after that, update each one to set a target_post. – JCarlosR Dec 03 '17 at 17:20