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 setup()
 {
     parent::setup();
     $account = new AdAccount($this->getConfig()->accountId);
     $this->adsPixel = $account->getAdsPixels()->current();
     if ($this->adsPixel === null) {
         throw new \Exception('Ads Pixel is null');
     }
     $this->productCatalog = new ProductCatalog(null, $this->getConfig()->businessId);
     $this->productCatalog->setData(array(ProductCatalogFields::NAME => $this->getConfig()->testRunId));
     $this->productCatalog->create();
     $this->productSet = new ProductSet(null, $this->productCatalog->{ProductCatalogFields::ID});
     $this->productSet->setData(array(ProductSetFields::NAME => $this->getConfig()->testRunId, ProductSetFields::FILTER => array('retailer_id' => array('is_any' => array('pid1', 'pid2')))));
     $this->productSet->create();
     $this->productAudience = new ProductAudience(null, $this->getConfig()->accountId);
     $this->productAudience->setData(array(ProductAudienceFields::NAME => $this->getConfig()->testRunId, 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->productAudience->create();
 }
Esempio n. 3
0
$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]
// use FacebookAds\Object\AdSet;