public function setup() { parent::setup(); $this->account = new AdAccount($this->getActId()); $cursor = $this->account->getAdsPixels(); $this->adsPixel = $cursor->current(); $this->productCatalog = new ProductCatalog(null, $this->getBusinessManagerId()); $this->productCatalog->setData(array(ProductCatalogFields::NAME => 'Test Catalog ' . $this->getTestRunId())); $this->productCatalog->create(); $this->productSet = new ProductSet(null, $this->productCatalog->{ProductCatalogFields::ID}); $this->productSet->setData(array(ProductSetFields::NAME => 'Test Set ' . $this->getTestRunId(), ProductSetFields::FILTER => array('retailer_id' => array('is_any' => array('pid1', 'pid2'))))); $this->productSet->create(); }
public function setup() { parent::setup(); $this->account = new AdAccount($this->getConfig()->accountId); $cursor = $this->account->getAdsPixels(); $this->adsPixel = $cursor->current(); $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(); }
/** * @depends testCreate */ public function testCrud() { $account = new AdAccount($this->getConfig()->accountId); $pixel = $account->getAdsPixels()->current(); $pixelId = $pixel->{AdsPixelsFields::ID}; $pixel = new AdsPixel($pixelId); $this->assertCanRead($pixel); $this->assertCanUpdate($pixel, array(AdsPixelsFields::NAME => $this->getConfig()->testRunId . ' updated')); $this->assertCannotDelete($pixel); }
public function testCrud() { $account = new AdAccount($this->getActId()); $pixels = $account->getAdsPixels(); $this->assertEquals(1, $pixels->count()); /** @var AdsPixel $pixel */ $pixel = $pixels->current(); $this->assertTrue($pixel instanceof AdsPixel); $pixelId = $pixel->{AdsPixelsFields::ID}; $pixel = new AdsPixel($pixelId); $this->assertCanRead($pixel); $this->assertCannotDelete($pixel); $this->assertCannotUpdate($pixel); }
/** * AdsPixels can be created but only one per account can exist */ public function testCreate() { // make sure there's at least one pixel $account = new AdAccount($this->getConfig()->accountId); $pixels = $account->getAdsPixels(); $pixel = null; if (!$pixels->count()) { $pixel = new AdsPixel(null, $this->getConfig()->accountId); $pixel->{AdsPixelsFields::NAME} = 'WCA Pixel'; $this->assertCanCreate($pixel); } else { $pixel = $pixels->current(); } $pixel = new AdsPixel(null, $this->getConfig()->accountId); $pixel->{AdsPixelsFields::NAME} = $this->getConfig()->testRunId; $this->assertCannotCreate($pixel); }
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(); }
// use FacebookAds\Object\Fields\AdGroupFields; $account = new AdAccount($ad_account_id); $params = array(AdGroupFields::ADGROUP_STATUS => array(AdGroup::STATUS_ACTIVE, AdGroup::STATUS_PAUSED, AdGroup::STATUS_CAMPAIGN_PAUSED, AdGroup::STATUS_CAMPAIGN_GROUP_PAUSED, AdGroup::STATUS_PENDING_REVIEW, AdGroup::STATUS_DISAPPROVED, AdGroup::STATUS_PREAPPROVED, AdGroup::STATUS_PENDING_BILLING_INFO, AdGroup::STATUS_ARCHIVED)); $adgroups = $account->getAdGroups(array(AdGroupFields::NAME), $params); // Outputs names of Ad Groups. foreach ($adgroups as $adgroup) { echo $adgroup->{AdGroupFields::NAME} . PHP_EOL; } // _DOC close [ADACCOUNT_GET_ADGROUPS_WITH_STATUS] unset($account); unset($adgroups); // _DOC open [ADACCOUNT_GET_ADSPIXELS] // _DOC vars [ad_account_id:s] // use FacebookAds\Object\AdAccount; $account = new AdAccount($ad_account_id); $pixels = $account->getAdsPixels(); // _DOC close [ADACCOUNT_GET_ADSPIXELS] // _DOC open [ADACCOUNT_GET_CUSTOMAUDIENCES] // _DOC vars [ad_account_id:s] // use FacebookAds\Object\AdAccount; $account = new AdAccount($ad_account_id); $audiences = $account->getCustomAudiences(); // _DOC close [ADACCOUNT_GET_CUSTOMAUDIENCES] // _DOC open [ADACCOUNT_GET_RATECARDS] // _DOC vars [ad_account_id:s] // use FacebookAds\Object\AdAccount; $account = new AdAccount($ad_account_id); $ratecards = $account->getRateCards(); // _DOC close [ADACCOUNT_GET_RATECARDS] // _DOC open [ADACCOUNT_GET_INSIGHTS_VIDEO_VIEWS] // _DOC vars [ad_account_id:s]
$audience->create(); $custom_audience_id = $audience->{CustomAudienceFields::ID}; $user_id_1 = 1234; $user_id_2 = 12345; // _DOC open [CUSTOM_AUDIENCE_USERS_ADD_ID] // _DOC vars [custom_audience_id:s, application_id, user_id_1, user_id_2] // use FacebookAds\Object\CustomAudience; // use FacebookAds\Object\Fields\CustomAudienceFields; // use FacebookAds\Object\Values\CustomAudienceTypes; // Add Facebook IDs of users of certain applications $audience = new CustomAudience($custom_audience_id); $audience->addUsers(array($user_id_1, $user_id_2), CustomAudienceTypes::ID, array($application_id)); // _DOC close [CUSTOM_AUDIENCE_USERS_ADD_ID] $audience->delete(); $account = new AdAccount($ad_account_id); $pixels = $account->getAdsPixels(array(AdsPixelsFields::CODE)); if (!$pixels->count()) { $pixel = new AdsPixel(null, $ad_account_id); $pixel->{AdsPixelsFields::NAME} = 'My WCA Pixel'; $pixel->create(); } else { $pixel = $pixels->current(); } $pixel_id = $pixel->{AdsPixelsFields::ID}; // _DOC open [CUSTOM_AUDIENCE_CREATE_WCA] // _DOC vars [ad_account_id:s, pixel_id] // use FacebookAds\Object\CustomAudience; // use FacebookAds\Object\Fields\CustomAudienceFields; // use FacebookAds\Object\Values\CustomAudienceSubtypes; $custom_audience = new CustomAudience(null, $ad_account_id); $custom_audience->setData(array(CustomAudienceFields::PIXEL_ID => $pixel_id, CustomAudienceFields::NAME => 'My New Website Custom Audience', CustomAudienceFields::SUBTYPE => CustomAudienceSubtypes::WEBSITE, CustomAudienceFields::RETENTION_DAYS => 15, CustomAudienceFields::RULE => array('url' => array('i_contains' => 'shoes')), CustomAudienceFields::PREFILL => true));