skip to Main Content

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


  1. 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 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]:

    curl -G 
      -d 'fields=name' 
      -d 'access_token=<ACCESS_TOKEN>' 
      https://graph.facebook.com/v2.11/act_<AD_ACCOUNT_ID>/adcreatives
    

    Then, read the detail of every creative [doc]:

    curl -G 
      -d 'fields=name,object_story_id' 
      -d 'access_token=<ACCESS_TOKEN>' 
      https://graph.facebook.com/v2.11/<CREATIVE_ID>
    

    Then read the detail of object_story_spec. As far as I see, the image and video URLs are in object_story_spec. Here is the field of object_story_spec doc:

    enter image description here

    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.

    Login or Signup to reply.
  2. @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,

    act_***************/ads?fields=name,insights{clicks},creative{name}&filtering=[{field: "id" , operator : "EQUAL", value: "*****" }]
    

    You can get both image and metrics about the Ad on the same request

    The Id in the filter is the Ad Id

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search