简体   繁体   中英

Reading Ad set fields with targeting in Facebook marketing API

I have using the marketing API version 2.6. In 2.5 version we can use the field targeting to retrieve the ads in the Ad Set. But in 2.6, Field targeting is not supported. I wanna to retrieve the age_min, age_max, geo_locations, and page_types. How to retrieve targeting fields in Ad Set? This is the code i have using to get the fields

if(is_null(ACCESS_TOKEN) || is_null(APP_ID) || is_null(APP_SECRET)) {
      throw new \Exception(
        'You must set your access token, app id and app secret before executing'
      );
    }
    if (is_null(ACCOUNT_ID)) {
      throw new \Exception(
        'You must set your account id before executing');
    }
    Api::init(APP_ID, APP_SECRET, ACCESS_TOKEN);
    $adSet      = new AdSet($adSetId);
    $fields     = array('name', 'targeting', 'creative', 'conversion_specs', 'redownload', 'genders', 'tracking_specs');
    $result     = $adSet->getAds($fields, $limit);

Maybe $result = $adSet->read($fields); Should work?

I think that "getAds" gets you the ads under the adset. Looks like you are interested in the adset's fields, not the ads under the adset.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM