Пример #1
0
 public function setup()
 {
     parent::setup();
     $targeting = new TargetingSpecs();
     $targeting->{TargetingSpecsFields::GEO_LOCATIONS} = array('countries' => array('US'));
     $this->campaign = new Campaign(null, $this->getConfig()->accountId);
     $this->campaign->{CampaignFields::NAME} = $this->getConfig()->testRunId;
     $this->campaign->create();
     $this->adSet = new AdSet(null, $this->getConfig()->accountId);
     $this->adSet->{AdSetFields::CAMPAIGN_ID} = (int) $this->campaign->{AdSetFields::ID};
     $this->adSet->{AdSetFields::NAME} = $this->getConfig()->testRunId;
     $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(array(AdSet::STATUS_PARAM_NAME => AdSet::STATUS_PAUSED));
     $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();
 }
 public function setup()
 {
     parent::setup();
     $targeting = new TargetingSpecs();
     $targeting->{TargetingSpecsFields::GEO_LOCATIONS} = array('countries' => array('US'));
     $this->campaign = new Campaign(null, $this->getConfig()->accountId);
     $this->campaign->{CampaignFields::NAME} = $this->getConfig()->testRunId;
     $this->campaign->create();
     $this->adSet = new AdSet(null, $this->getConfig()->accountId);
     $this->adSet->{AdSetFields::CAMPAIGN_ID} = (int) $this->campaign->{AdSetFields::ID};
     $this->adSet->{AdSetFields::NAME} = $this->getConfig()->testRunId;
     $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->{AdFields::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(array(AdSet::STATUS_PARAM_NAME => AdSet::STATUS_PAUSED));
     $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->ad = new Ad(null, $this->getConfig()->accountId);
     $this->ad->{AdFields::NAME} = $this->getConfig()->testRunId;
     $this->ad->{AdFields::ADSET_ID} = (int) $this->adSet->{AdSetFields::ID};
     $this->ad->{AdFields::CREATIVE} = array('creative_id' => $this->adCreative->{AdCreativeFields::ID});
     $this->ad->create(array(Ad::STATUS_PARAM_NAME => Ad::STATUS_PAUSED));
 }
Пример #3
0
 public function setup()
 {
     parent::setup();
     $this->campaign = new Campaign(null, $this->getConfig()->accountId);
     $this->campaign->{CampaignFields::NAME} = $this->getConfig()->testRunId;
     $this->campaign->create();
 }
Пример #4
0
 private function createCampaign()
 {
     $campaign = new Campaign(null, 'act_' . $this->adAccountId);
     $campaign->setData(array(CampaignFields::NAME => 'My Campaign ' . date("Y-m-d H:i:s"), CampaignFields::OBJECTIVE => AdObjectives::VIDEO_VIEWS));
     $campaign->create(array(Campaign::STATUS_PARAM_NAME => Campaign::STATUS_PAUSED));
     return $campaign->getData()[Campaign::FIELD_ID];
 }