Good morning to all.
Recently I was working on the Facebook API trying to extract the images of the ads from an advertising account. The problem I have is to use creative to get the image_url field I realize that only some ads in my account return the image_url, that is, I can’t get all the images as I want.
I also tried with thumbnail_url but it returns me images clipped in miniature, you can modify its dimensions with thumbnail_height and thumbnail_width but all it does is enlarge the image in pixels but the cropping of them continues.
My response request to the Facebook API is this:
GET https://graph.facebook.com/v5.0/act_131251207293544?fields=ads{id,name,creative{image_url,status}}
I don’t know if any of you know another way to extract these ad images so that all the ads have their corresponding image at the time of consulting the API and this displayed in its original size.
I thank you very much for your collaboration
2
Answers
I worked with Facebook SDK for years, and I developed a similar feature like that.
First of all, read all the ad creativities of your account[doc]:
Then, read the detail of every creative [doc]:
Then read the detail of
object_story_spec
. As far as I see, the image and video URLs are inobject_story_spec
. Here is the field ofobject_story_spec
doc:The data you want should in
photo_data
.But be aware! The
object_story_spec
varies from the type of ad,so you should do it very carefully.
For example, if it’s a video ad or text ad, there may be no
photo_data
at all.If you have any questions, please no hesitate to leave a comment here.
@Sayakiss answers is partially correct.
If I understand well :
In some cases when Dynamic content is not active on Facebook Ads the relation is one image for one ad. (1 to 1)
Look at this request,
You can get both image and metrics about the Ad on the same request
The Id in the filter is the Ad Id