1

我正在使用 Facebook Marketing Api 创建广告和自定义受众。我怎么找不到将创建的自定义受众链接到 Adset 的方法。下面是github中可用的示例。目前我只能创建具有兴趣和地理位置的广告集。

如下例所示,我们只能按兴趣和地理位置定位。

$results = TargetingSearch::search(
  $type = TargetingSearchTypes::INTEREST,
  $class = null,
  $query = 'facebook');
// we'll take the top result for now
$target = (count($results)) ? $results->current() : null;
echo "Using target: ".$target->name."\n";
$targeting = new TargetingSpecs();
$targeting->{TargetingSpecsFields::GEO_LOCATIONS}
  = array('countries' => array('GB'));
$targeting->{TargetingSpecsFields::INTERESTS} = array(
    array(
        'id' => $target->id,
        'name' => $target->name,
    ),
);


$adset = new AdSet(null, $account->id);
$adset->setData(array(
  AdSetFields::NAME => 'My First AdSet',
  AdSetFields::CAMPAIGN_ID => $campaign->id,
  AdSetFields::STATUS => AdSet::STATUS_ACTIVE,
  AdSetFields::DAILY_BUDGET => '150',
  AdSetFields::TARGETING => $targeting,
  AdSetFields::OPTIMIZATION_GOAL => OptimizationGoals::REACH,
  AdSetFields::BILLING_EVENT => BillingEvents::IMPRESSIONS,
  AdSetFields::BID_AMOUNT => 2,
  AdSetFields::START_TIME =>
    (new \DateTime("+1 week"))->format(\DateTime::ISO8601),
  AdSetFields::END_TIME =>
    (new \DateTime("+2 week"))->format(\DateTime::ISO8601),
));
$adset->validate()->create();
echo 'AdSet  ID: '. $adset->id . "\n";

我的要求是将自定义受众直接链接到 Adset,例如 AdSetFields::CUSTOMAUDIENCE => $audienceid

这至少可能吗?如果不能,我们如何将我们创建的自定义受众与 Adset 关联?

4

1 回答 1

1

您可以使用接受一组自定义受众来定位的字段 custom_audiences。我不确定该名称是否实际上也需要,但是在所有示例中都有:

$targeting->{TargetingSpecsFields::CUSTOM_AUDIENCES} = array(
  array(
    'id' => <AUDIENCE_ID>,
    'name' => <AUDIENCE_NAME>,
  ),
);

请参阅定位文档并搜索“定位自定义受众和合作伙伴类别”

于 2015-11-26T11:39:20.230 回答