public function testCrudAccess() { $audience_name = 'Test Audience ' . $this->getTestRunId(); $this->adsPixel->{AdsPixelsFields::ID}; $audience = new ProductAudience(null, $this->getActId()); $audience->setData(array(ProductAudienceFields::NAME => $audience_name, ProductAudienceFields::PRODUCT_SET_ID => $this->productSet->{ProductSetFields::ID}, ProductAudienceFields::PIXEL_ID => $this->adsPixel->{AdsPixelsFields::ID}, ProductAudienceFields::INCLUSIONS => array(array('retention_seconds' => 86400, 'rule' => array('and' => array(array('event' => array('eq' => 'ViewContent')), array('userAgent' => array('i_contains' => 'iPhone')))))))); $this->assertCanCreate($audience); $this->assertCanRead($audience); $this->assertCanUpdate($audience, array(ProductAudienceFields::NAME => $audience_name . ' updated')); $this->assertCanDelete($audience); }
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(); }
$adset->delete(); $campaign->delete(); // Create AdCampaign $campaign = new AdCampaign(null, $ad_account_id); $campaign->setData(array(AdCampaignFields::NAME => 'My First Campaign', AdCampaignFields::OBJECTIVE => AdObjectives::WEBSITE_CLICKS, AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED)); $campaign->create(); $campaign_group_id = $campaign->{AdCampaignFields::ID}; $product_catalog = new ProductCatalog(null, $business_id); $product_catalog->setData(array(ProductCatalogFields::NAME => 'Test Catalog')); $product_catalog->create(); $catalog_id = $product_catalog->{ProductCatalogFields::ID}; $product_set = new ProductSet(null, $catalog_id); $product_set->setData(array(ProductSetFields::NAME => 'Test Catalog Set')); $product_set->create(); $product_set_id = $product_set->{ProductSetFields::ID}; $product_audience = new ProductAudience(null, $ad_account_id); $product_audience->setData(array(ProductAudienceFields::NAME => 'Test Custom Audience', ProductAudienceFields::PRODUCT_SET_ID => $product_set_id, ProductAudienceFields::INCLUSIONS => array(array('retention_seconds' => 86400, 'rule' => array('event' => array('eq' => 'AddToCart')))))); $product_audience->create(); $dynamic_audience_id = $product_audience->{ProductAudienceFields::ID}; // _DOC open [ADSET_CREATE_PRODUCT_CATALOG_SALES] // _DOC vars [ad_account_id:s, campaign_group_id, dynamic_audience_id, product_set_id] // use FacebookAds\Object\AdSet; // use FacebookAds\Object\Fields\AdSetFields; // use FacebookAds\Object\Fields\TargetingSpecsFields; $adset = new AdSet(null, $ad_account_id); $adset->setData(array(AdSetFields::NAME => 'Product Catalog Sales Adset', AdSetFields::BID_AMOUNT => 3000, AdSetFields::BILLING_EVENT => BillingEvents::LINK_CLICKS, AdSetFields::OPTIMIZATION_GOAL => OptimizationGoals::LINK_CLICKS, AdSetFields::CAMPAIGN_STATUS => AdCampaign::STATUS_ACTIVE, AdSetFields::DAILY_BUDGET => 15000, AdSetFields::CAMPAIGN_GROUP_ID => $campaign_group_id, AdSetFields::TARGETING => array(TargetingSpecsFields::GEO_LOCATIONS => array('countries' => array('US')), TargetingSpecsFields::DYNAMIC_AUDIENCE_IDS => array($dynamic_audience_id)), AdSetFields::PROMOTED_OBJECT => array('product_set_id' => $product_set_id))); $adset->create(); // _DOC close [ADSET_CREATE_PRODUCT_CATALOG_SALES] $adset->delete(); // _DOC open [ADSET_CREATE_PRODUCT_CATALOG_SALES_VIEWED_DAYS_RETENTION] // _DOC vars [ad_account_id:s, campaign_group_id, product_set_id]