3

Is there any way to use the Facebook API (or other method) to get the image URL for my ad images? I have a list of image hashes, but how can I get their URLs?

Alternatively, is there another way to get the URL of my ad images without relying on the hash? I am trying to download them all systematically.

Geoff
  • 71
  • 1
  • 3
  • Go via the `adaccount/adimages` edge, and request the `url` field? https://developers.facebook.com/docs/marketing-api/reference/ad-image#examples_read – CBroe Feb 27 '20 at 07:52

1 Answers1

2

Yes! Get the permalink_url of an image using the /adimages edge off the adaccount node. You can also return the hash value and filter the query by a list of specific hashes:

https://graph.facebook.com/v13/act_<AD_ACCOUNT_ID>/adimages?
    fields=id,permalink_url, 
    hash&hashes=["<IMAGE_HASH_1>","<IMAGE_HASH_2>"]

This returns:

{
  "data": [
    {
      "id": "<AD_IMAGE_ID>",
      "permalink_url": "https://www.facebook.com/ads/image/?d=<UNIQUE_NUMBER>",
      "hash": "<IMAGE_HASH_1>"
    },
    {
      "id": "<AD_IMAGE_ID>",
      "permalink_url": "https://www.facebook.com/ads/image/?d=<UNIQUE_NUMBER>",
      "hash": "<IMAGE_HASH_2>"
    },
  ],
  "paging": {
    "cursors": {
      "before": "<VALUE>",
      "after": "<VALUE>"
    }
  }
}
Meli
  • 467
  • 4
  • 10