예제 #1
0
 public function setup()
 {
     parent::setup();
     $this->adCampaign = new AdCampaign(null, $this->getConfig()->accountId);
     $this->adCampaign->{AdCampaignFields::NAME} = $this->getConfig()->testRunId;
     $this->adCampaign->create();
 }
 public function setup()
 {
     parent::setup();
     $targeting = new TargetingSpecs();
     $targeting->{TargetingSpecsFields::GEO_LOCATIONS} = array('countries' => array('US'));
     $this->adCampaign = new AdCampaign(null, $this->getConfig()->accountId);
     $this->adCampaign->{AdCampaignFields::NAME} = $this->getConfig()->testRunId;
     $this->adCampaign->create();
     $this->adSet = new AdSet(null, $this->getConfig()->accountId);
     $this->adSet->{AdSetFields::CAMPAIGN_GROUP_ID} = (int) $this->adCampaign->{AdSetFields::ID};
     $this->adSet->{AdSetFields::NAME} = $this->getConfig()->testRunId;
     $this->adSet->{AdSetFields::CAMPAIGN_STATUS} = AdSet::STATUS_PAUSED;
     $this->adSet->{AdSetFields::DAILY_BUDGET} = '150';
     $this->adSet->{AdSetFields::START_TIME} = (new \DateTime("+1 week"))->format(\DateTime::ISO8601);
     $this->adSet->{AdSetFields::END_TIME} = (new \DateTime("+2 week"))->format(\DateTime::ISO8601);
     $this->adSet->{AdSetFields::TARGETING} = $targeting;
     $this->adSet->{AdSetFields::OPTIMIZATION_GOAL} = OptimizationGoals::REACH;
     $this->adSet->{AdSetFields::BILLING_EVENT} = BillingEvents::IMPRESSIONS;
     $this->adSet->{AdSetFields::BID_AMOUNT} = 2;
     $this->adSet->save();
     $this->adImage = new AdImage(null, $this->getConfig()->accountId);
     $this->adImage->{AdImageFields::FILENAME} = $this->getConfig()->testImagePath;
     $this->adImage->save();
     $link = new LinkData();
     $link->{LinkDataFields::MESSAGE} = 'Message';
     $link->{LinkDataFields::IMAGE_HASH} = $this->adImage->{AdImageFields::HASH};
     $link->{LinkDataFields::LINK} = $this->getConfig()->appUrl;
     $story = new ObjectStorySpec();
     $story->{ObjectStorySpecFields::PAGE_ID} = $this->getConfig()->pageId;
     $story->{ObjectStorySpecFields::LINK_DATA} = $link;
     $this->adCreative = new AdCreative(null, $this->getConfig()->accountId);
     $this->adCreative->{AdCreativeFields::OBJECT_STORY_SPEC} = $story;
     $this->adCreative->create();
 }
예제 #3
0
 public function setup()
 {
     parent::setup();
     $this->adCampaign = new AdCampaign(null, $this->getActId());
     $this->adCampaign->{AdCampaignFields::NAME} = $this->getTestRunId();
     $this->adCampaign->create();
 }
 public function setup()
 {
     parent::setup();
     $this->adCampaign = new AdCampaign(null, $this->getActId());
     $this->adCampaign->{AdCampaignFields::NAME} = $this->getTestRunId();
     $this->adCampaign->create();
     $this->adSet = new AdSet(null, $this->getActId());
     $this->adSet->{AdSetFields::CAMPAIGN_GROUP_ID} = (int) $this->adCampaign->{AdSetFields::ID};
     $this->adSet->{AdSetFields::NAME} = $this->getTestRunId();
     $this->adSet->{AdSetFields::CAMPAIGN_STATUS} = AdSet::STATUS_PAUSED;
     $this->adSet->{AdSetFields::DAILY_BUDGET} = '150';
     $this->adSet->{AdSetFields::START_TIME} = (new \DateTime("+1 week"))->format(\DateTime::ISO8601);
     $this->adSet->{AdSetFields::END_TIME} = (new \DateTime("+2 week"))->format(\DateTime::ISO8601);
     $this->adSet->create();
     $this->adImage = new AdImage(null, $this->getActId());
     $this->adImage->{AdImageFields::FILENAME} = $this->getTestImagePath();
     $this->adImage->save();
     $this->adCreative = new AdCreative(null, $this->getActId());
     $this->adCreative->{AdCreativeFields::TITLE} = 'My Test Ad';
     $this->adCreative->{AdCreativeFields::BODY} = 'My Test Ad Body';
     $this->adCreative->{AdCreativeFields::OBJECT_ID} = $this->getPageId();
     $this->adCreative->{AdCreativeFields::IMAGE_HASH} = $this->adImage->{AdImageFields::HASH};
     $this->adCreative->create();
     $targeting = new TargetingSpecs();
     $targeting->{TargetingSpecsFields::GEO_LOCATIONS} = array('countries' => array('US'));
     $this->adGroup = new AdGroup(null, $this->getActId());
     $this->adGroup->{AdGroupFields::ADGROUP_STATUS} = AdGroup::STATUS_PAUSED;
     $this->adGroup->{AdGroupFields::NAME} = $this->getTestRunId();
     $this->adGroup->{AdGroupFields::BID_TYPE} = AdGroup::BID_TYPE_CPM;
     $this->adGroup->{AdGroupFields::BID_INFO} = array(AdGroupBidInfoFields::IMPRESSIONS => '2');
     $this->adGroup->{AdGroupFields::CAMPAIGN_ID} = (int) $this->adSet->{AdSetFields::ID};
     $this->adGroup->{AdGroupFields::TARGETING} = $targeting;
     $this->adGroup->{AdGroupFields::CREATIVE} = array('creative_id' => $this->adCreative->{AdCreativeFields::ID});
     $this->adGroup->create();
 }
 public function setup()
 {
     parent::setup();
     $this->adCampaign = new AdCampaign(null, $this->getActId());
     $this->adCampaign->{AdCampaignFields::NAME} = $this->getTestRunId();
     $this->adCampaign->create();
     $this->adSet = new AdSet(null, $this->getActId());
     $this->adSet->{AdSetFields::CAMPAIGN_GROUP_ID} = (int) $this->adCampaign->{AdSetFields::ID};
     $this->adSet->{AdSetFields::NAME} = $this->getTestRunId();
     $this->adSet->{AdSetFields::CAMPAIGN_STATUS} = AdSet::STATUS_PAUSED;
     $this->adSet->{AdSetFields::DAILY_BUDGET} = '150';
     $this->adSet->{AdSetFields::START_TIME} = (new \DateTime("+1 week"))->format(\DateTime::ISO8601);
     $this->adSet->{AdSetFields::END_TIME} = (new \DateTime("+2 week"))->format(\DateTime::ISO8601);
     $this->adSet->save();
     $this->adImage = new AdImage(null, $this->getActId());
     $this->adImage->{AdImageFields::FILENAME} = $this->getTestImagePath();
     $this->adImage->save();
     $this->adCreative = new AdCreative(null, $this->getActId());
     $this->adCreative->{AdCreativeFields::TITLE} = 'My Test Ad';
     $this->adCreative->{AdCreativeFields::BODY} = 'My Test Ad Body';
     $this->adCreative->{AdCreativeFields::OBJECT_ID} = $this->getPageId();
     $this->adCreative->create();
 }
 public function setup()
 {
     parent::setup();
     $targeting = new TargetingSpecs();
     $targeting->{TargetingSpecsFields::GEO_LOCATIONS} = array('countries' => array('US'));
     $this->adCampaign = new AdCampaign(null, $this->getConfig()->accountId);
     $this->adCampaign->{AdCampaignFields::NAME} = $this->getConfig()->testRunId;
     $this->adCampaign->create();
     $this->adSet = new AdSet(null, $this->getConfig()->accountId);
     $this->adSet->{AdSetFields::CAMPAIGN_GROUP_ID} = (int) $this->adCampaign->{AdSetFields::ID};
     $this->adSet->{AdSetFields::NAME} = $this->getConfig()->testRunId;
     $this->adSet->{AdSetFields::CAMPAIGN_STATUS} = AdSet::STATUS_PAUSED;
     $this->adSet->{AdSetFields::DAILY_BUDGET} = '150';
     $this->adSet->{AdSetFields::START_TIME} = (new \DateTime("+1 week"))->format(\DateTime::ISO8601);
     $this->adSet->{AdSetFields::END_TIME} = (new \DateTime("+2 week"))->format(\DateTime::ISO8601);
     $this->adSet->{AdGroupFields::TARGETING} = $targeting;
     $this->adSet->{AdSetFields::OPTIMIZATION_GOAL} = OptimizationGoals::REACH;
     $this->adSet->{AdSetFields::BILLING_EVENT} = BillingEvents::IMPRESSIONS;
     $this->adSet->{AdSetFields::BID_AMOUNT} = 2;
     $this->adSet->create();
     $this->adImage = new AdImage(null, $this->getConfig()->accountId);
     $this->adImage->{AdImageFields::FILENAME} = $this->getConfig()->testImagePath;
     $this->adImage->save();
     $this->adCreative = new AdCreative(null, $this->getConfig()->accountId);
     $this->adCreative->{AdCreativeFields::TITLE} = 'My Test Ad';
     $this->adCreative->{AdCreativeFields::BODY} = 'My Test Ad Body';
     $this->adCreative->{AdCreativeFields::OBJECT_ID} = $this->getConfig()->pageId;
     $this->adCreative->{AdCreativeFields::IMAGE_HASH} = $this->adImage->{AdImageFields::HASH};
     $this->adCreative->create();
     $this->adGroup = new AdGroup(null, $this->getConfig()->accountId);
     $this->adGroup->{AdGroupFields::ADGROUP_STATUS} = AdGroup::STATUS_PAUSED;
     $this->adGroup->{AdGroupFields::NAME} = $this->getConfig()->testRunId;
     $this->adGroup->{AdGroupFields::CAMPAIGN_ID} = (int) $this->adSet->{AdSetFields::ID};
     $this->adGroup->{AdGroupFields::CREATIVE} = array('creative_id' => $this->adCreative->{AdCreativeFields::ID});
     $this->adGroup->create();
 }
예제 #7
0
// use FacebookAds\Object\Values\AdObjectives;
$campaign = new AdCampaign(null, $ad_account_id);
$campaign->setData(array(AdCampaignFields::NAME => 'Video Views Campaign', AdCampaignFields::OBJECTIVE => AdObjectives::VIDEO_VIEWS, AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED));
$campaign->create();
// _DOC close [ADCAMPAIGN_CREATE_VIDEO_VIEWS]
$campaign->delete();
// _DOC open [ADCAMPAIGN_CREATE_LOCAL_AWARENESS]
// _DOC vars [ad_account_id:s]
// use FacebookAds\Object\AdCampaign;
// use FacebookAds\Object\AdCampaignFields;
// use FacebookAds\Object\Values\AdObjectives;
$campaign = new AdCampaign(null, $ad_account_id);
$campaign->setData(array(AdCampaignFields::NAME => 'Local awareness campaign', AdCampaignFields::OBJECTIVE => AdObjectives::LOCAL_AWARENESS, AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED));
$campaign->create();
// _DOC close [ADCAMPAIGN_CREATE_LOCAL_AWARENESS]
$campaign->delete();
$product_catalog = new ProductCatalog(null, $business_id);
$product_catalog->setData(array(ProductCatalogFields::NAME => 'Test Catalog'));
$product_catalog->create();
$product_catalog_id = $product_catalog->{ProductCatalogFields::ID};
// _DOC open [ADCAMPAIGN_CREATE_OBJECTIVE_PRODUCT_CATELOG_SALES]
// _DOC vars [ad_account_id:s, product_catalog_id]
// use FacebookAds\Object\AdCampaign;
// use FacebookAds\Object\Fields\AdCampaignFields;
// use FacebookAds\Object\Values\AdObjectives;
$campaign = new AdCampaign(null, $ad_account_id);
$campaign->setData(array(AdCampaignFields::NAME => 'Product Catalog Sales Campaign Group', AdCampaignFields::OBJECTIVE => AdObjectives::PRODUCT_CATALOG_SALES, AdCampaignFields::STATUS => AdCampaign::STATUS_PAUSED, AdCampaignFields::PROMOTED_OBJECT => array('product_catalog_id' => $product_catalog_id)));
$campaign->create();
// _DOC close [ADCAMPAIGN_CREATE_OBJECTIVE_PRODUCT_CATELOG_SALES]
$campaign->delete();
$product_catalog->delete();