public function setup()
 {
     parent::setup();
     $this->adLabel = new AdLabel(null, $this->getConfig()->accountId);
     $this->adLabel->{AdLabelFields::NAME} = $this->getConfig()->testRunId;
     $this->adLabel->create();
 }
Esempio n. 2
0
$account->{AdAccountFields::NAME} = $account_name;
$account->update();
unset($account);
// _DOC open [ADACCOUNT_GET_ADCAMPAIGNS]
// _DOC vars [ad_account_id:s]
// use FacebookAds\Object\AdAccount;
// use FacebookAds\Object\Fields\AdCampaignFields;
$account = new AdAccount($ad_account_id);
$campaigns = $account->getAdCampaigns(array(AdCampaignFields::NAME));
foreach ($campaigns as $campaign) {
    echo $campaign->{AdCampaignFields::NAME} . PHP_EOL;
}
// _DOC close [ADACCOUNT_GET_ADCAMPAIGNS]
$label = new AdLabel(null, $ad_account_id);
$label->{AdLabelFields::NAME} = 'ADACCOUNT_GET_ADCAMPAIGNS_LABEL';
$label->create();
$ad_label_id = $label->{AdLabelFields::ID};
// _DOC open [ADACCOUNT_GET_ADLABELS]
// _DOC vars [ad_account_id:s]
// use FacebookAds\Object\AdAccount;
$account = new AdAccount($ad_account_id);
$account->getAdLabels();
// _DOC close [ADACCOUNT_GET_ADLABELS]
// _DOC open [ADACCOUNT_GET_ADCAMPAIGNS_ADLABEL]
// _DOC vars [ad_account_id:s]
// use FacebookAds\Object\AdAccount;
$account = new AdAccount($ad_account_id);
$campaigns = $account->getAdCampaignsByLabel(array(), array('ad_label_ids' => array($ad_label_id)));
// _DOC close [ADACCOUNT_GET_ADCAMPAIGNS_ADLABEL]
// _DOC open [ADACCOUNT_GET_ADSETS_ADLABEL]
// _DOC vars [ad_account_id:s]
 /**
  * @param AdLabelAwareCrudObjectTrait|AbstractCrudObject $object
  */
 public function assertCanBeLabeled(AbstractCrudObject $object)
 {
     $label = new AdLabel(null, $this->getConfig()->accountId);
     $label->{AdLabelFields::NAME} = $this->getConfig()->testRunId;
     $label->create();
     /** @var AdLabelAwareCrudObjectTrait|AbstractCrudObject $mirror */
     $mirror = $this->getEmptyClone($object);
     $mirror->addAdLabels(array($label->{AdLabelFields::ID}));
     $mirror = $this->getEmptyClone($object);
     $mirror->read(array('adlabels'));
     $this->assertCount(1, $mirror->{'adlabels'});
     $mirror = $this->getEmptyClone($object);
     $mirror->removeAdLabels(array($label->{AdLabelFields::ID}));
     $mirror->read(array('adlabels'));
     $this->assertNull($mirror->{'adlabels'});
     $label->delete();
 }