/** * (non-PHPdoc) * @see BaseExample::run() */ public function run() { $values = $this->formValues; printf('<h2>Creating placement with name "%s" under campaign ID %s</h2>', $values['placement_name'], $values['campaign_id']); // Retrieve the campaign. $campaign = $this->service->campaigns->get($values['user_profile_id'], $values['campaign_id']); $placement = new Google_Service_Dfareporting_Placement(); $placement->setCampaignId($values['campaign_id']); $placement->setCompatibility('WEB'); $placement->setName($values['placement_name']); $placement->setPaymentSource('PLACEMENT_AGENCY_PAID'); $placement->setSiteId($values['site_id']); $placement->setTagFormats(array('PLACEMENT_TAG_STANDARD')); // Set the size of the placement. $size = new Google_Service_Dfareporting_Size(); $size->setId($values['size_id']); $placement->setSize($size); // Set the pricing schedule for the placement. $pricing_schedule = new Google_Service_Dfareporting_PricingSchedule(); $pricing_schedule->setEndDate($campaign->getEndDate()); $pricing_schedule->setPricingType('PRICING_TYPE_CPM'); $pricing_schedule->setStartDate($campaign->getStartDate()); $placement->setPricingSchedule($pricing_schedule); // Insert the placement. $result = $this->service->placements->insert($values['user_profile_id'], $placement); $this->printResultsTable('Placement created.', array($result)); }
/** * (non-PHPdoc) * @see BaseExample::run() */ public function run() { $values = $this->formValues; printf('<h2>Creating HTML5 banner banner creative from HTML5 asset "%s"</h2>', $values['html_asset_file']['name']); $creative = new Google_Service_Dfareporting_Creative(); $creative->setAdvertiserId($values['advertiser_id']); $creative->setAutoAdvanceImages(true); $creative->setName('Test HTML5 banner creative'); $creative->setType('HTML5_BANNER'); $size = new Google_Service_Dfareporting_Size(); $size->setId($values['size_id']); $creative->setSize($size); // Upload the flash asset. $html_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['html_asset_file'], 'HTML'); $html_asset = new Google_Service_Dfareporting_CreativeAsset(); $html_asset->setAssetIdentifier($html_asset_id); $html_asset->setRole('PRIMARY'); // Upload the backup image asset. $image_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['image_asset_file'], 'HTML_IMAGE'); $image_asset = new Google_Service_Dfareporting_CreativeAsset(); $image_asset->setAssetIdentifier($image_asset_id); $image_asset->setRole('BACKUP_IMAGE'); // Add the creative assets. $creative->setCreativeAssets(array($html_asset, $image_asset)); // Add a click tag. $click_tag = new Google_Service_Dfareporting_ClickTag(); $click_tag->setName('clickTag'); $creative->setClickTags(array($click_tag)); $result = $this->service->creatives->insert($values['user_profile_id'], $creative); $this->printResultsTable('HTML5 banner creative created.', array($result)); }
/** * (non-PHPdoc) * @see BaseExample::run() */ public function run() { $values = $this->formValues; printf('<h2>Creating flash in-page banner creative from flash asset "%s"</h2>', $values['flash_asset_file']['name']); $creative = new Google_Service_Dfareporting_Creative(); $creative->setAdvertiserId($values['advertiser_id']); $creative->setAutoAdvanceImages(true); $creative->setName('Test flash in-page creative'); $creative->setType('FLASH_INPAGE'); $size = new Google_Service_Dfareporting_Size(); $size->setId($values['size_id']); $creative->setSize($size); // Upload the flash asset. $flash_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['flash_asset_file'], 'FLASH'); $flash_asset = new Google_Service_Dfareporting_CreativeAsset(); $flash_asset->setAssetIdentifier($flash_asset_id); $flash_asset->setRole('PRIMARY'); $flash_asset->setWindowMode('TRANSPARENT'); // Upload the backup image asset. $image_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['image_asset_file'], 'HTML_IMAGE'); $image_asset = new Google_Service_Dfareporting_CreativeAsset(); $image_asset->setAssetIdentifier($image_asset_id); $image_asset->setRole('BACKUP_IMAGE'); // Add the creative assets. $creative->setCreativeAssets(array($flash_asset, $image_asset)); // Set up the backup image target window option. $target_window = new Google_Service_Dfareporting_TargetWindow(); $target_window->setTargetWindowOption('NEW_WINDOW'); $creative->setBackupImageTargetWindow($target_window); $result = $this->service->creatives->insert($values['user_profile_id'], $creative); $this->printResultsTable('Flash in-page creative created.', array($result)); }
/** * (non-PHPdoc) * @see BaseExample::run() */ public function run() { $values = $this->formValues; printf('<h2>Creating redirect creative from image URL "%s"</h2>', $values['image_url']); $creative = new Google_Service_Dfareporting_Creative(); $creative->setAdvertiserId($values['advertiser_id']); $creative->setName('Test redirect creative'); $creative->setRedirectUrl($values['image_url']); $creative->setType('REDIRECT'); $size = new Google_Service_Dfareporting_Size(); $size->setId($values['size_id']); $creative->setSize($size); $result = $this->service->creatives->insert($values['user_profile_id'], $creative); $this->printResultsTable('Redirect creative created.', array($result)); }
/** * (non-PHPdoc) * @see BaseExample::run() */ public function run() { $values = $this->formValues; printf('<h2>Creating image creative from image asset "%s"</h2>', $values['asset_file']['name']); $creative = new Google_Service_Dfareporting_Creative(); $creative->setAdvertiserId($values['advertiser_id']); $creative->setName('Test image creative'); $creative->setType('IMAGE'); $size = new Google_Service_Dfareporting_Size(); $size->setId($values['size_id']); $creative->setSize($size); // Upload the image asset. $asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['asset_file'], 'IMAGE'); $asset = new Google_Service_Dfareporting_CreativeAsset(); $asset->setAssetIdentifier($asset_id); $asset->setRole('PRIMARY'); // Add the creative asset. $creative->setCreativeAssets(array($asset)); $result = $this->service->creatives->insert($values['user_profile_id'], $creative); $this->printResultsTable('Image creative created.', array($result)); }
/** * (non-PHPdoc) * @see BaseExample::run() */ public function run() { $values = $this->formValues; printf('<h2>Creating enhanced banner creative from HTML5 asset "%s"</h2>', $values['html_asset_file']['name']); $creative = new Google_Service_Dfareporting_Creative(); $creative->setAdvertiserId($values['advertiser_id']); $creative->setName('Test enhanced banner creative'); $creative->setType('ENHANCED_BANNER'); $size = new Google_Service_Dfareporting_Size(); $size->setId($values['size_id']); $creative->setSize($size); // Upload the HTML5 asset. $html_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['html_asset_file'], 'HTML'); $html_asset = new Google_Service_Dfareporting_CreativeAsset(); $html_asset->setAssetIdentifier($html_asset_id); $html_asset->setRole('PRIMARY'); $html_asset->setWindowMode('TRANSPARENT'); // Upload the backup image asset. $image_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['image_asset_file'], 'HTML_IMAGE'); $image_asset = new Google_Service_Dfareporting_CreativeAsset(); $image_asset->setAssetIdentifier($image_asset_id); $image_asset->setRole('BACKUP_IMAGE'); // Add the creative assets. $creative->setCreativeAssets(array($html_asset, $image_asset)); // Configure the backup image. $creative->setBackupImageClickThroughUrl('https://www.google.com'); $creative->setBackupImageReportingLabel('backup'); $target_window = new Google_Service_Dfareporting_TargetWindow(); $target_window->setTargetWindowOption('NEW_WINDOW'); $creative->setBackupImageTargetWindow($target_window); // Add a click tag. $click_tag = new Google_Service_Dfareporting_ClickTag(); $click_tag->setName('clickTag'); $click_tag->setEventName('exit'); $click_tag->setValue('https://www.google.com'); $creative->setClickTags(array($click_tag)); $result = $this->service->creatives->insert($values['user_profile_id'], $creative); $this->printResultsTable('Enhanced banner creative created.', array($result)); }
/** * (non-PHPdoc) * @see BaseExample::run() */ public function run() { $values = $this->formValues; printf('<h2>Creating enhanced banner creative from images "%s" and "%s"</h2>', $values['image1_asset_file']['name'], $values['image2_asset_file']['name']); $creative = new Google_Service_Dfareporting_Creative(); $creative->setAdvertiserId($values['advertiser_id']); $creative->setAutoAdvanceImages(true); $creative->setName('Test enhanced image creative'); $creative->setType('ENHANCED_IMAGE'); $size = new Google_Service_Dfareporting_Size(); $size->setId($values['size_id']); $creative->setSize($size); // Upload the first image asset. $image1_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['image1_asset_file'], 'HTML_IMAGE'); $image1_asset = new Google_Service_Dfareporting_CreativeAsset(); $image1_asset->setAssetIdentifier($image1_asset_id); $image1_asset->setRole('PRIMARY'); // Upload the second image asset. $image2_asset_id = uploadAsset($this->service, $values['user_profile_id'], $values['advertiser_id'], $values['image2_asset_file'], 'HTML_IMAGE'); $image2_asset = new Google_Service_Dfareporting_CreativeAsset(); $image2_asset->setAssetIdentifier($image2_asset_id); $image2_asset->setRole('PRIMARY'); // Add the creative assets. $creative->setCreativeAssets(array($image1_asset, $image2_asset)); // Add a click tag for the first image asset. $click_tag1 = new Google_Service_Dfareporting_ClickTag(); $click_tag1->setName($image1_asset_id->getName()); $click_tag1->setEventName($image1_asset_id->getName()); // Add a click tag for the second image asset. $click_tag2 = new Google_Service_Dfareporting_ClickTag(); $click_tag2->setName($image2_asset_id->getName()); $click_tag2->setEventName($image2_asset_id->getName()); $creative->setClickTags(array($click_tag1, $click_tag2)); $result = $this->service->creatives->insert($values['user_profile_id'], $creative); $this->printResultsTable('Enhanced image creative created.', array($result)); }