如何在创建广告时将已保存的受众群体用作定位规范

I am trying to create an adset with targeting specs and assign saved_audience id as a targeting specs. I looked at the API docs of targeting spec: https://developers.facebook.com/docs/marketing-api/targeting-specs/v2.8

It talks about custom_audience but not saved_audience. I tried to send it as a parameter saved_audience, saved_audiences etc. thinking that maybe it is not documented. API response is invalid parameter.

Here is the code:

$set->setData(array(
        AdSetFields::NAME => $obj_page->title.' '.time(),
        AdSetFields::CAMPAIGN_ID => $campaign_id,
        AdSetFields::DAILY_BUDGET => $daily_budget,
        AdSetFields::BID_AMOUNT => $daily_budget,
        AdSetFields::START_TIME => (new \DateTime($request->start_time))->format(\DateTime::ISO8601),
        AdSetFields::END_TIME => (new \DateTime($request->end_time))->format(\DateTime::ISO8601),
        AdSetFields::BILLING_EVENT => AdSetBillingEventValues::IMPRESSIONS,
        AdSetFields::TARGETING => (new Targeting())->setData(array(
            'custom_audiences' => array($audience_id), // works
            TargetingFields::PUBLISHER_PLATFORMS => array('facebook'),
            TargetingFields::DEVICE_PLATFORMS => array('desktop'),
        ))
    ));

using 'saved_audience' => array($audience_id) doesn't work.

There is no way to specify saved_audiences in the targeting spec. For more info on all the possible fields refer to the SDK.

https://github.com/facebook/facebook-java-ads-sdk/blob/master/src/main/java/com/facebook/ads/sdk/Targeting.java

I've been dealing with the same problem (check my Stackoverflow question) and my conclusion is that it isn't possible right now. A work-around is to retrieve the targeting spec from your saved audience in a separate API call and copy over these settings to the new ad you're creating. Disadvantage is that when updating the saved audience, your ad won't be updated.