0

With facebook ad api, I can send a query to retrieve ad image information.

The following is the examples from facebook doc. https://developers.facebook.com/docs/reference/ads-api/adimage/v2.2

curl -G \
-d "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/act_<ACCOUNT_ID>/adimages"

curl -G \
-d "hashes=[%220d500843a1d4699a0b41e99f4137a5c3%22,%22012feg987e98g789f789e87976210983%22]" \
-d "access_token=<ACCESS_TOKEN>" \
"https://graph.facebook.com/act_<AD_ACCOUNT_ID>"

Both calls work fine. But the problem is: they return just the array of image id and image hash, nothing else. Again, example from facebook doc. My test shows response with the same format.

{
    "data": {
       {
         "hash": "0d500843a1d4699a0b41e99f4137a5c3", 
         "id": "16522000:0d500843a1d4699a0b41e99f4137a5c3"
       }, 
       {
         "hash": "012feg987e98g789f789e87976210983", 
         "id": "16522001:012feg987e98g789f789e87976210983"
       }
     }, 
   "paging": {
     "cursors": {
       "before": "NDIyNDAzMzc0NDY4NjQxOjE2...",
        "after": "NDIyNDAzMzc0NDY4NjQxOmU5Njg..."
     }
   }
}

Ad Image objects are supposed to have 'url', 'width', 'height', properties. But I cannot retrieve anything more than id and hash, whatever I try.

Any way to get thumbnail url or other image properties using image hash or ad account id?

What I want to achieve ultimately is make a migration from manual management to automatic api based management, and get the url/properties of images already uploaded to facebook (to be saved in db and reused when necessary).

1 Answers1

0

Like almost for all the Ad Objects, if you call an Ad Image endpoint without specifying any additional fields you only get and id and, sometimes, a few more parameters.

If you look carefully in the section "Create" of that page you'll find a list of fields; Add the needed one as a field param in your curl request.

Ex.

curl -G \
-d "access_token=<ACCESS_TOKEN>" \
-d "fields=id,url,whatever" \
"https://graph.facebook.com/act_<ACCOUNT_ID>/adimages"
ilpaijin
  • 3,645
  • 2
  • 23
  • 26