本文整理汇总了PHP中DateTimeUtils::GetDfpDateTime方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeUtils::GetDfpDateTime方法的具体用法?PHP DateTimeUtils::GetDfpDateTime怎么用?PHP DateTimeUtils::GetDfpDateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeUtils
的用法示例。
在下文中一共展示了DateTimeUtils::GetDfpDateTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: LineItem
$lineItem = new LineItem();
$lineItem->name = 'Line item #' . uniqid();
$lineItem->orderId = $orderId;
$lineItem->targeting = $targeting;
$lineItem->lineItemType = 'STANDARD';
$lineItem->allowOverbook = 'TRUE';
// Create the creative placeholder.
$creativePlaceholder = new CreativePlaceholder();
$creativePlaceholder->size = new Size(300, 250, FALSE);
// Set the size of creatives that can be associated with this line item.
$lineItem->creativePlaceholders = array($creativePlaceholder);
// Set the creative rotation type to even.
$lineItem->creativeRotationType = 'EVEN';
// Set the length of the line item to run.
$lineItem->startDateTimeType = 'IMMEDIATELY';
$lineItem->endDateTime = DateTimeUtils::GetDfpDateTime(new DateTime('+1 month'));
// Set the cost per unit to $2.
$lineItem->costType = 'CPM';
$lineItem->costPerUnit = new Money('USD', 2000000);
// Set the number of units bought to 500,000 so that the budget is
// $1,000.
$lineItem->unitsBought = 500000;
$lineItem->unitType = 'IMPRESSIONS';
$lineItems[] = $lineItem;
}
// Create the line items on the server.
$lineItems = $lineItemService->createLineItems($lineItems);
// Display results.
if (isset($lineItems)) {
foreach ($lineItems as $lineItem) {
print 'A line item with with ID "' . $lineItem->id . '", belonging to order ID "' . $lineItem->orderId . '", and name "' . $lineItem->name . "\" was created.\n";
示例2: InventoryTargeting
$lineItem->lineItemType = 'SPONSORSHIP';
// Create inventory targeting.
$inventoryTargeting = new InventoryTargeting();
$inventoryTargeting->targetedPlacementIds = array($targetPlacementId);
// Set targeting for line item.
$targeting = new Targeting();
$targeting->inventoryTargeting = $inventoryTargeting;
$lineItem->targeting = $targeting;
// Create the creative placeholder.
$creativePlaceholder = new CreativePlaceholder();
$creativePlaceholder->size = new Size(300, 250, FALSE);
// Set the size of creatives that can be associated with this line item.
$lineItem->creativePlaceholders = array($creativePlaceholder);
// Set the line item's time to be now until the projected end date time.
$lineItem->startDateTimeType = 'IMMEDIATELY';
$lineItem->endDateTime = DateTimeUtils::GetDfpDateTime(new DateTime('+1 week'));
// Set the line item to use 50% of the impressions.
$lineItem->unitType = 'IMPRESSIONS';
$lineItem->unitsBought = 50;
// Set the cost type to match the unit type.
$lineItem->costType = 'CPM';
// Get forecast for line item.
$forecast = $forecastService->getForecast($lineItem);
// Display results.
$matchedUnits = $forecast->matchedUnits;
$percentAvailableUnits = $forecast->availableUnits / $matchedUnits * 100;
$unitType = strtolower($forecast->unitType);
printf("%d %s matched.\n", $matchedUnits, $unitType);
printf("%d%% %s available.\n", $percentAvailableUnits, $unitType);
if (isset($forecast->possibleUnits)) {
$percentPossibleUnits = $forecast->possibleUnits / $matchedUnits * 100;
示例3: Size
$lineItem->roadblockingType = 'ONE_OR_MORE';
// Set the creative rotation type.
$lineItem->creativeRotationType = 'OPTIMIZED';
// Create the creative placeholder size.
$size = new Size();
$size->width = 300;
$size->height = 250;
$size->isAspectRatio = false;
// Create the creative placeholder.
$creativePlaceholder = new CreativePlaceholder();
$creativePlaceholder->size = $size;
// Set the size of creatives that can be associated with this line item.
$lineItem->creativePlaceholders = array($creativePlaceholder);
// Set the length of the line item to run.
$lineItem->startDateTimeType = 'IMMEDIATELY';
$lineItem->endDateTime = DateTimeUtils::GetDfpDateTime(new DateTime('+30 days', new DateTimeZone('America/New_York')));
// Set the cost type.
$lineItem->costType = 'CPM';
// Set the line item to use 50% of the impressions.
$goal = new Goal();
$goal->goalType = 'DAILY';
$goal->unitType = 'IMPRESSIONS';
$goal->units = 50;
$lineItem->primaryGoal = $goal;
// Get forecast for prospective line item.
$prospectiveLineItem = new ProspectiveLineItem();
$prospectiveLineItem->lineItem = $lineItem;
$options = new AvailabilityForecastOptions();
$options->includeContendingLineItems = true;
$options->includeTargetingCriteriaBreakdown = true;
$forecast = $forecastService->getAvailabilityForecast($prospectiveLineItem, $options);