public function tearDown()
 {
     if ($this->productSet) {
         $this->productSet->delete();
         $this->productSet = null;
     }
     if ($this->productCatalog) {
         $this->productCatalog->delete();
         $this->productCatalog = null;
     }
     if ($this->productAudience) {
         $this->productAudience->delete();
         $this->productAudience = null;
     }
     if ($this->adCampaign) {
         $this->adCampaign->delete();
         $this->adCampaign = null;
     }
     if ($this->adSet) {
         $this->adSet->delete();
         $this->adSet = null;
     }
     if ($this->adGroup) {
         $this->adGroup->delete();
         $this->adGroup = null;
     }
     if ($this->creative) {
         $this->creative->delete();
         $this->creative = null;
     }
     parent::tearDown();
 }
 public function tearDown()
 {
     if ($this->adGroup) {
         $this->adGroup->delete();
         $this->adGroup = null;
     }
     if ($this->adSet) {
         $this->adSet->delete();
         $this->adSet = null;
     }
     if ($this->adCampaign) {
         $this->adCampaign->delete();
         $this->adCampaign = null;
     }
     if ($this->adCreative) {
         $this->adCreative->delete();
         $this->adCreative = null;
     }
     if ($this->adImage) {
         $this->adImage->delete();
         $this->adImage = null;
     }
     parent::tearDown();
 }
Exemplo n.º 3
0
// Then, use the image hash returned from above
$creative = new AdCreative(null, $ad_account_id);
$creative->setData(array(AdCreativeFields::TITLE => 'My Test Creative', AdCreativeFields::BODY => 'My Test Ad Creative Body', AdCreativeFields::OBJECT_URL => 'https://www.facebook.com/facebook', AdCreativeFields::IMAGE_HASH => $image_hash));
// Finally, create your ad along with ad creative.
// Please note that the ad creative is not created independently, rather its
// data structure is appended to the ad group
$adgroup = new AdGroup(null, $ad_account_id);
$adgroup->setData(array(AdGroupFields::NAME => 'My Ad', AdGroupFields::CAMPAIGN_ID => $ad_set_id, AdGroupFields::CREATIVE => $creative, AdGroupFields::ADGROUP_STATUS => AdGroup::STATUS_PAUSED));
$adgroup->create();
// _DOC close [ADGROUP_CREATE_INLINE_CREATIVE]
// fetch the id of the generated creative
$adgroup->read(array(AdGroupFields::CREATIVE));
$creative->{AdCreativeFields::ID} = $adgroup->{AdGroupFields::CREATIVE}['id'];
// _DOC open [ADGROUP_GET_TARGETING_DESCRIPTION]
// _DOC vars [ad_group_id]
// use FacebookAds\Object\AdGroup;
$adgroup = new AdGroup($ad_group_id);
$targeting_description = $adgroup->getTargetingDescription();
// Output targeting description
foreach ($targeting_description->targetingsentencelines as $description) {
    echo $description['content'] . PHP_EOL;
    foreach ($description['children'] as $child) {
        echo "\t" . $child . PHP_EOL;
    }
}
// _DOC close [ADGROUP_GET_TARGETING_DESCRIPTION]
$adgroup->delete();
$adset->delete();
$campaign->delete();
$creative->delete();
$image->delete();