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();
 }
Ejemplo n.º 2
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 testMultiProductObjectSpec()
 {
     // Create a new AdCreative
     $creative = new AdCreative(null, $this->getActId());
     $creative->{AdCreativeFields::NAME} = 'Multi Product Ad Creative';
     // Create a new ObjectStorySpec to create an unpublished post
     $story = new ObjectStorySpec();
     $story->{ObjectStorySpecFields::PAGE_ID} = $this->getPageId();
     // Create LinkData object representing data for a link page post
     $link = new LinkData();
     $link->{LinkDataFields::LINK} = $this->getAppUrl();
     $link->{LinkDataFields::CAPTION} = 'My Caption';
     // Upload a test image to use in Attachments
     $adImage = new AdImage(null, $this->getActId());
     $adImage->{AdImageFields::FILENAME} = $this->getTestImagePath();
     $adImage->save();
     // Create 3 products as this will be a multi-product ad
     $product1 = (new AttachmentData())->setData(array(AttachmentDataFields::LINK => $this->getAppUrl() . 'p1', AttachmentDataFields::IMAGE_HASH => $adImage->hash, AttachmentDataFields::NAME => 'Product 1', AttachmentDataFields::DESCRIPTION => '$100'));
     $product2 = (new AttachmentData())->setData(array(AttachmentDataFields::LINK => $this->getAppUrl() . 'p2', AttachmentDataFields::IMAGE_HASH => $adImage->hash, AttachmentDataFields::NAME => 'Product 2', AttachmentDataFields::DESCRIPTION => '$200'));
     $product3 = (new AttachmentData())->setData(array(AttachmentDataFields::LINK => $this->getAppUrl() . 'p3', AttachmentDataFields::IMAGE_HASH => $adImage->hash, AttachmentDataFields::NAME => 'Product 3', AttachmentDataFields::DESCRIPTION => '$300'));
     // Add the products into the child attachments
     $link->{LinkDataFields::CHILD_ATTACHMENTS} = array($product1, $product2, $product3);
     $story->{ObjectStorySpecFields::LINK_DATA} = $link;
     $creative->{AdCreativeFields::OBJECT_STORY_SPEC} = $story;
     $this->assertCanCreate($creative);
     $this->assertCanDelete($creative);
 }
 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));
 }
Ejemplo n.º 5
0
 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();
 }