按广告系列ID获取AdSets

时间:2016-09-02 12:43:25

标签: php facebook-marketing-api

我'使用此方法为Facebook Markiting API进行广告系列。它完美地运作:

$account = new AdAccount($account_id);

$campaigns = $account->getCampaigns(array(
        CampaignFields::ID,
        CampaignFields::NAME,
        CampaignFields::OBJECTIVE,
        CampaignFields::STATUS,
        CampaignFields::CREATED_TIME,
        CampaignFields::START_TIME,
        CampaignFields::STOP_TIME,
        CampaignFields::UPDATED_TIME,
    )
);

返回广告系列ID。我试图按广告系列ID获取广告。
我使用此代码但未返回任何内容:

$adsets = (new AdSet($camp_id))->read(array(
  AdSetFields::NAME,

));


foreach ($adsets as $adset) {
  echo '<br />--<br />';
  echo $adset->{AdSetFields::ID}.PHP_EOL;

  echo '<br />---<br />';

}

1 个答案:

答案 0 :(得分:0)

阅读一个广告系列中的所有广告集

use FacebookAds\Object\AdCampaign;
use FacebookAds\Object\Fields\AdSetFields;

$adcampaign = new AdCampaign($adcampaign_id);
$adsets = $adcampaign->getAdSets(array(
  AdSetFields::NAME,
  AdSetFields::CAMPAIGN_STATUS
));

// This will output the name of all fetched ad sets.
foreach ($adsets as $adset) {
  echo $adset->name;
}

Ad Campaign