public function tearDown()
 {
     if ($this->adLabel !== null) {
         $this->adLabel->delete();
         $this->adLabel = null;
     }
     parent::tearDown();
 }
示例#2
0
 public function createAdLabel(array $fields = array(), array $params = array(), $pending = false)
 {
     $this->assureId();
     $param_types = array('name' => 'string');
     $enums = array();
     $request = new ApiRequest($this->api, $this->data['id'], RequestInterface::METHOD_POST, '/adlabels', new AdLabel(), 'EDGE', AdLabel::getFieldsEnum()->getValues(), new TypeChecker($param_types, $enums));
     $request->addParams($params);
     $request->addFields($fields);
     return $pending ? $request : $request->execute();
 }
$account->update();
// _DOC close [ADACCOUNT_UPDATE]
$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]
$campaign->{AdCampaignFields::NAME} = 'My new campaign name';
$campaign->validate();
$campaign->update();
// _DOC close [ADCAMPAIGN_VALIDATE]
// _DOC open [ADCAMPAIGN_GET_ADSETS]
// _DOC vars [campaign_group_id]
// use FacebookAds\Object\AdCampaign;
// use FacebookAds\Object\Fields\AdSetFields;
$campaign = new AdCampaign($campaign_group_id);
$adsets = $campaign->getAdSets(array(AdSetFields::NAME, AdSetFields::CAMPAIGN_STATUS));
// This will output the name of all fetched ad sets.
foreach ($adsets as $adset) {
    echo $adset->{AdSetFields::NAME} . PHP_EOL;
}
// _DOC close [ADCAMPAIGN_GET_ADSETS]
$label = new AdLabel(null, $ad_account_id);
$label->{AdLabelFields::NAME} = 'ADCAMPAIGN_ADD_LABELS';
$label->create();
$ad_label_id = $label->{AdLabelFields::ID};
// _DOC open [ADCAMPAIGN_ADD_LABELS]
// _DOC vars [campaign_group_id]
// use FacebookAds\Object\AdCampaign;
$campaign = new AdCampaign($campaign_group_id);
$campaign->addAdLabels(array($ad_label_id));
// _DOC close [ADCAMPAIGN_ADD_LABELS]
// _DOC open [ADCAMPAIGN_REMOVE_LABELS]
// _DOC vars [campaign_group_id]
// use FacebookAds\Object\AdCampaign;
$campaign = new AdCampaign($campaign_group_id);
$campaign->removeAdLabels(array($ad_label_id));
// _DOC close [ADCAMPAIGN_REMOVE_LABELS]
示例#5
0
 public function createAdLabel(array $fields = array(), array $params = array(), $pending = false)
 {
     $this->assureId();
     $param_types = array('adlabels' => 'list<Object>', 'execution_options' => 'list<execution_options_enum>');
     $enums = array('execution_options_enum' => AdLabelExecutionOptionsValues::getInstance()->getValues());
     $request = new ApiRequest($this->api, $this->data['id'], RequestInterface::METHOD_POST, '/adlabels', new AdLabel(), 'EDGE', AdLabel::getFieldsEnum()->getValues(), new TypeChecker($param_types, $enums));
     $request->addParams($params);
     $request->addFields($fields);
     return $pending ? $request : $request->execute();
 }
 /**
  * @param array $fields
  * @param array $params
  * @return Cursor
  */
 public function getAdLabels(array $fields = array(), array $params = array())
 {
     return $this->getManyByConnection(AdLabel::className(), $fields, $params);
 }
 /**
  * @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();
 }
示例#8
0
use FacebookAdsTest\Config\Config;
/** @var Config $config */
$ad_account_id = $config->accountId;
// _DOC open [ADLABEL_CREATE]
// _DOC vars [ad_account_id:s]
// use FacebookAds\Object\AdLabel;
// use FacebookAds\Object\Fields\AdLabelFields;
$label = new AdLabel(null, $ad_account_id);
$label->{AdLabelFields::NAME} = 'AdLabel name';
$label->create();
// _DOC close [ADLABEL_CREATE]
$ad_label_id = $label->{AdLabelFields::ID};
// _DOC open [ADLABEL_READ]
// _DOC vars [ad_label_id]
// use FacebookAds\Object\AdLabel;
$label = new AdLabel($ad_label_id);
$label->read();
// _DOC close [ADLABEL_READ]
// _DOC open [ADLABEL_UPDATE]
// _DOC vars [ad_label_id]
// use FacebookAds\Object\AdLabel;
// use FacebookAds\Object\Fields\AdLabelFields;
$label = new AdLabel($ad_label_id);
$label->{AdLabelFields::NAME} = 'New AdLabel name';
$label->read();
// _DOC close [ADLABEL_UPDATE]
// _DOC open [ADLABEL_DELETE]
// _DOC vars [ad_label_id]
$label = new AdLabel($ad_label_id);
$label->delete();
// _DOC close [ADLABEL_DELETE]