5

I'm using the Facebook Graph API v2.8 to get a page feed like this:

/page-id/posts?fields=attachments{media,title},id,message...

If a post has attachments I want my request to return the full size image for each attachment in the attachments.media.image path. Currently it only returns a square image in standard size (380x380px to max 720x720px).

Is there any way to further specify the query to achieve this? Something like:

fields=attachments{media{image.type(full)},title]},id....

If possible I don't want to make another request to the media/object endpoint.

PS: The url in the current response points to a php service and has a width and a height parameter in it which can be left out to get the full size image.

https://external.xx.fbcdn.net/safe_image.php?d=AQAkZcYtE-TiVzTj&w=542&h=542&url=fbstaging%3A%2F%2Fgraph.facebook.com%2Fstaging_resources%2FMDExMDE1NDcxNzI3Njg3Mjc2MDoxMjE3ODEyMjE%3D&cfs=1&sx=104&sy=0&sw=542&sh=542&l

However since there is also a hash in that URL I really don't want to do regex stuff to remove the width and height parameter of the response image url to get the fullsize image.

Edit: Also I can't really use the full_picture field, since it will only give me the URL for the first (main) attachment. I'm looking for the media URLs of all attachments.

Attachment Reference

Ahmad Ferdous
  • 3,351
  • 16
  • 33
lukash
  • 668
  • 1
  • 5
  • 10
  • not sure if you are looking for this but for post I did like this: https://graph.facebook.com/".$fbID."/?fields=id,name,access_token,posts{full_picture,message,likes,link,created_time} – Tomas Lucena Nov 25 '16 at 10:49
  • 3
    Thanks for your reply! full_picture would work just fine if there is only 1 attachment for each post, however there might be multiple attachments (subattachments) for a post. full_picture will only give me the first (main) attachment url. – lukash Nov 25 '16 at 11:03

1 Answers1

0

I have not yet found a way to get the high resolution image URLs in the initial query. I think it must be done in separate steps.

1. Getting photos posted to the feed

https://graph.facebook.com/v15.0/YOUR_PAGE_ID/feed?fields=attachments&access_token=...

2. Getting high resolution imagery

The image URLs provided by the query above will often only provide resolutions up to 720px. If you want higher resolution images, then you need to find the target.id for each subattachment, and perform a separate graph query for each image to obtain the other resolutions. It looks like this:

https://graph.facebook.com/v15.0/YOUR_IMAGE_ID?fields=images&access_token=...

This answer was taken from another more detailed answer that I contributed to, here.

Simon East
  • 55,742
  • 17
  • 139
  • 133