Typical usage is:

$statementBuilder = new StatementBuilder()
    ->Where("lastModifiedDateTime > :yesterday AND type = :type")
    ->OrderBy("name DESC")
    ->Limit(200)
    ->Offset(20)
    ->WithBindVariableValue("yesterday",
        date(DateTimeUtils::$DFP_DATE_TIME_STRING_FORMAT,
            strtotime('-1 day'))
    ->WithBindVariableValue("type", "Type")

$statement = $statementBuilder->ToStatement();
...
$statementBuilder->IncreaseOffsetBy(20);
$statement = $statementBuilder->ToStatement();
예제 #1
0
 public function syncDFPAPIplacement()
 {
     // Get the PlacementService.
     $placementService = $this->dfp_user->GetService('PlacementService', 'v201508');
     // Create a statement to select all placements.
     $statementBuilder = new StatementBuilder();
     $statementBuilder->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT);
     // Get placements by statement.
     $page = $placementService->getPlacementsByStatement($statementBuilder->ToStatement());
     // Display results.
     if (isset($page->results)) {
         foreach ($page->results as $placement) {
             $data[] = array($placement->id, $placement->name);
         }
     }
     $field = array('dp_id', 'dp_name');
     return $this->insert($this->table, $data, $field);
 }
예제 #2
0
 public function syncDFPAPIadvertiser()
 {
     $data = array();
     // Get the CompanyService.
     $companyService = $this->dfp_user->GetService('CompanyService', 'v201508');
     // Create a statement to select only companies that are advertisers.
     $statementBuilder = new StatementBuilder();
     $statementBuilder->Where('type = :type')->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT)->WithBindVariableValue('type', 'ADVERTISER');
     // Get companies by statement.
     $page = $companyService->getCompaniesByStatement($statementBuilder->ToStatement());
     // Display results.
     if (isset($page->results)) {
         foreach ($page->results as $company) {
             $row = $this->getAdvertiserById($company->id);
             if (!isset($row[0])) {
                 $data[] = array($company->id, $company->name);
             }
         }
     }
     $field = array('dfp_adv_id', 'dfp_adv_name');
     return $this->insert($this->table, $data, $field, false);
 }
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201602/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the ID of the reconciliation report to retrieve line item reports for.
$reconciliationReportId = 'INSERT_RECONCILIATION_REPORT_ID_HERE';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the ReconciliationLineItemReportService.
    $reconciliationLineItemReportService = $user->GetService('ReconciliationLineItemReportService', 'v201602');
    // Create a statement to select reconciliation line item reports for DFP line
    // items.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('reconciliationReportId = :reconciliationReportId ' . 'AND lineItemId != :lineItemId')->OrderBy('lineItemId ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT)->WithBindVariableValue('reconciliationReportId', $reconciliationReportId)->WithBindVariableValue('lineItemId', 0);
    // Default for total result set size.
    $totalResultSetSize = 0;
    do {
        // Get reconciliation line item reports by statement.
        $page = $reconciliationLineItemReportService->getReconciliationLineItemReportsByStatement($statementBuilder->ToStatement());
        // Display results.
        if (isset($page->results)) {
            $totalResultSetSize = $page->totalResultSetSize;
            $i = $page->startIndex;
            foreach ($page->results as $reconciliationLineItemReport) {
                printf("%d) Reconciliation line item report with ID %d for line item ID " . "%d was found, with reconciliation source '%s' and " . "reconciled volume '%d'.\n", $i++, $reconciliationLineItemReport->id, $reconciliationLineItemReport->lineItemId, $reconciliationLineItemReport->reconciliationSource, $reconciliationLineItemReport->reconciledVolume);
            }
        }
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
// DfpUser.php directly via require_once.
// $path = '/path/to/dfp_api_php_lib/src';
$path = dirname(__FILE__) . '/../../../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201502/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the InventoryService.
    $inventoryService = $user->GetService('InventoryService', 'v201502');
    // Create a statement to select all ad unit sizes.
    $statementBuilder = new StatementBuilder();
    // Get all ad unit sizes by statement.
    $adUnitSizes = $inventoryService->getAdUnitSizesByStatement($statementBuilder->ToStatement());
    // Display results.
    foreach ($adUnitSizes as $i => $adUnitSize) {
        printf("%d) Ad unit size of dimensions %s was found.\n", $i, $adUnitSize->fullDisplayString);
    }
    printf("Number of ad unit sizes found: %d\n", count($adUnitSizes));
} catch (OAuth2Exception $e) {
    ExampleUtils::CheckForOAuth2Errors($e);
} catch (ValidationException $e) {
    ExampleUtils::CheckForOAuth2Errors($e);
} catch (Exception $e) {
    printf("%s\n", $e->getMessage());
}
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201502/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the ID of the company to update.
$companyId = 'INSERT_COMPANY_ID_HERE';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the CompanyService.
    $companyService = $user->GetService('CompanyService', 'v201502');
    // Create a statement to select a single company by ID.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('id = :id')->OrderBy('id ASC')->Limit(1)->WithBindVariableValue('id', $companyId);
    // Get the company.
    $page = $companyService->getCompaniesByStatement($statementBuilder->ToStatement());
    $company = $page->results[0];
    // Update the comment.
    $company->comment = sprintf('%s - updated.', $company->comment);
    // Update the company on the server.
    $companies = $companyService->updateCompanies(array($company));
    foreach ($companies as $updatedCompany) {
        printf("Company with ID %d, name '%s', and comment '%s' was updated.\n", $updatedCompany->id, $updatedCompany->name, $updatedCompany->comment);
    }
} catch (OAuth2Exception $e) {
    ExampleUtils::CheckForOAuth2Errors($e);
} catch (ValidationException $e) {
    ExampleUtils::CheckForOAuth2Errors($e);
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201602/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the rate card ID to filter base rates on.
$rateCardId = 'INSERT_RATE_CARD_ID_HERE';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the BaseRateService.
    $baseRateService = $user->GetService('BaseRateService', 'v201602');
    // Create a statement to select only base rates belonging to a rate card.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('rateCardId = :rateCardId')->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT)->WithBindVariableValue('rateCardId', $rateCardId);
    // Default for total result set size.
    $totalResultSetSize = 0;
    do {
        // Get base rates by statement.
        $page = $baseRateService->getBaseRatesByStatement($statementBuilder->ToStatement());
        // Display results.
        if (isset($page->results)) {
            $totalResultSetSize = $page->totalResultSetSize;
            $i = $page->startIndex;
            foreach ($page->results as $baseRate) {
                printf("%d) Base rate with ID %d, and type '%s', belonging to rate " . "card ID %d was found.\n", $i++, $baseRate->id, get_class($baseRate), $baseRate->rateCardId);
            }
        }
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
예제 #7
0
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201508/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the ID of the line item to deactivate LICAs for.
$lineItemId = 'INSERT_LINE_ITEM_ID_HERE';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the LineItemCreativeAssociationService.
    $licaService = $user->GetService('LineItemCreativeAssociationService', 'v201508');
    // Create a statement to select all LICAs for a line item.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('lineItemId = :lineItemId')->OrderBy('lineItemId ASC, creativeId ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT)->WithBindVariableValue('lineItemId', $lineItemId);
    // Default for total result set size.
    $totalResultSetSize = 0;
    do {
        // Get LICAs by statement.
        $page = $licaService->getLineItemCreativeAssociationsByStatement($statementBuilder->ToStatement());
        // Display results.
        if (isset($page->results)) {
            $totalResultSetSize = $page->totalResultSetSize;
            $i = $page->startIndex;
            foreach ($page->results as $lica) {
                if (isset($lica->creativeSetId)) {
                    printf("%d) LICA with line item ID %d, and creative set ID %d will " . "be deactivated.\n", $i++, $lica->lineItemId, $lica->creativeSetId);
                } else {
                    printf("%d) LICA with line item ID %d, and creative ID %d will be " . "deactivated.\n", $i++, $lica->lineItemId, $lica->creativeId);
예제 #8
0
    $customCriteria3->keyId = $customCriteriaIds3[0];
    $customCriteria3->valueIds = array($customCriteriaIds3[1]);
    $customCriteria3->operator = 'IS';
    // Create the custom criteria set that will resemble:
    //
    // ($customCriteria1.key == $customCriteria1.value OR
    //     ($customCriteria2.key != $customCriteria2.value AND
    //         $customCriteria3.key == $customCriteria3.value))
    $topCustomCriteriaSet = new CustomCriteriaSet();
    $topCustomCriteriaSet->logicalOperator = 'OR';
    $subCustomCriteriaSet = new CustomCriteriaSet();
    $subCustomCriteriaSet->logicalOperator = 'AND';
    $subCustomCriteriaSet->children = array($customCriteria2, $customCriteria3);
    $topCustomCriteriaSet->children = array($customCriteria1, $subCustomCriteriaSet);
    // Create a statement to select a single line item by ID.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('id = :id')->OrderBy('id ASC')->Limit(1)->WithBindVariableValue($lineItemId);
    // Get the line item.
    $results = $lineItemService->getLineItemsByStatement($statementBuilder->ToStatement())->results;
    $lineItem = $results[0];
    // Set the custom criteria targeting on the line item.
    $lineItem->targeting->customTargeting = $topCustomCriteriaSet;
    // Update the line item on the server.
    $lineItems = $lineItemService->updateLineItems(array($lineItem));
    foreach ($lineItems as $lineItem) {
        printf("Line item with ID %d was updated.\n", $lineItem->id);
    }
} catch (OAuth2Exception $e) {
    ExampleUtils::CheckForOAuth2Errors($e);
} catch (ValidationException $e) {
    ExampleUtils::CheckForOAuth2Errors($e);
require_once 'Google/Api/Ads/Dfp/Util/v201608/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the ID of the content metadata key hierarchy to update.
$contentMetadataKeyHierarchyId = 'INSERT_CONTENT_METADATA_KEY_HIERARCHY_ID_HERE';
// Set the ID of the custom targeting key to be added as a hierarchy level.
$customTargetingKeyId = 'INSERT_CUSTOM_TARGETING_KEY_ID_HERE';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the ContentMetadataKeyHierarchyService.
    $contentMetadataKeyHierarchyService = $user->GetService('ContentMetadataKeyHierarchyService', 'v201608');
    // Create a statement to select a single content metadata key hierarchy by ID.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('id = :id')->OrderBy('id ASC')->Limit(1)->WithBindVariableValue('id', $contentMetadataKeyHierarchyId);
    // Get the content metadata key hierarchy.
    $page = $contentMetadataKeyHierarchyService->getContentMetadataKeyHierarchiesByStatement($statementBuilder->ToStatement());
    $contentMetadataKeyHierarchy = $page->results[0];
    // Update the content metadata key hierarchy by adding a hierarchy level.
    $hierarchyLevels = $contentMetadataKeyHierarchy->hierarchyLevels;
    $hierarchyLevel = new ContentMetadataKeyHierarchyLevel();
    $hierarchyLevel->customTargetingKeyId = $customTargetingKeyId;
    $hierarchyLevel->hierarchyLevel = count($hierarchyLevels) + 1;
    $contentMetadataKeyHierarchy->hierarchyLevels[] = $hierarchyLevel;
    // Update the content metadata key hierarchy on the server.
    $contentMetadataKeyHierarchies = $contentMetadataKeyHierarchyService->updateContentMetadataKeyHierarchies(array($contentMetadataKeyHierarchy));
    foreach ($contentMetadataKeyHierarchies as $updatedContentMetadataKeyHierarchy) {
        printf("Content metadata key hierarchy with ID %d, and name '%s' was " . "updated.\n", $updatedContentMetadataKeyHierarchy->id, $updatedContentMetadataKeyHierarchy->name);
    }
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201505/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the ID of the creative wrapper label to deactivate.
$labelId = 'INSERT_CREATIVE_WRAPPER_LABEL_ID_HERE';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the CreativeWrapperService.
    $creativeWrapperService = $user->GetService('CreativeWrapperService', 'v201505');
    // Create a statement to select the active creative wrappers for the given
    // label.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('labelId = :labelId')->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT)->WithBindVariableValue('labelId', $labelId);
    // Default for total result set size.
    $totalResultSetSize = 0;
    do {
        // Get creative wrappers by statement.
        $page = $creativeWrapperService->getCreativeWrappersByStatement($statementBuilder->ToStatement());
        // Display results.
        if (isset($page->results)) {
            $totalResultSetSize = $page->totalResultSetSize;
            $i = $page->startIndex;
            foreach ($page->results as $creativeWrapper) {
                printf("%d) Creative wrapper with ID %d, applying to label with ID %d, " . "with status %s will be deactivated.\n", $i++, $creativeWrapper->id, $creativeWrapper->labelId, $creativeWrapper->status);
            }
        }
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
// $path = '/path/to/dfp_api_php_lib/src';
$path = dirname(__FILE__) . '/../../../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201608/Pql.php';
require_once 'Google/Api/Ads/Dfp/Util/v201608/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    $pqlService = $user->GetService('PublisherQueryLanguageService', 'v201608');
    // Create statement to select all programmatic buyers.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Select('BuyerAccountId, Name')->From('Programmatic_Buyer')->OrderBy('BuyerAccountId ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT);
    // Retrieve a small amount of rows at a time, paging through until all rows
    // have been retrieved.
    $resultSet = null;
    $combinedResultSet = null;
    $i = 0;
    do {
        $resultSet = $pqlService->select($statementBuilder->ToStatement());
        // Combine result sets with previous ones.
        $combinedResultSet = $combinedResultSet !== null ? $resultSet : Pql::CombineResultSets($combinedResultSet, $resultSet);
        printf("%d) %d programmatic buyers beginning at offset %d were found.\n", $i++, $resultSet->rows !== null ? count($resultSet->rows) : 0, $statementBuilder->GetOffset());
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
    } while ($resultSet->rows !== null && count($resultSet->rows) > 0);
    // Change to another file location if desired.
    $filePath = sprintf("%s/programmatic-buyers-%s.csv", sys_get_temp_dir(), uniqid());
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201602/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the ID of the base rate to update.
$baseRateId = 'INSERT_BASE_RATE_ID_HERE';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the BaseRateService.
    $baseRateService = $user->GetService('BaseRateService', 'v201602');
    // Create a statement to select a single base rate by ID.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('id = :id')->OrderBy('id ASC')->Limit(1)->WithBindVariableValue('id', $baseRateId);
    // Get the base rate.
    $page = $baseRateService->getBaseRatesByStatement($statementBuilder->ToStatement());
    $baseRate = $page->results[0];
    // Update base rate value to $3 USD.
    $newRate = new Money();
    $newRate->currencyCode = 'USD';
    $newRate->microAmount = 3000000;
    $baseRate->rate = $newRate;
    // Update the base rate on the server.
    $baseRates = $baseRateService->updateBaseRates(array($baseRate));
    foreach ($baseRates as $updatedBaseRate) {
        printf("Base rate with ID %d and type '%s', belonging to rate card ID %d " . "was updated.\n", $updatedBaseRate->id, get_class($updatedBaseRate), $updatedBaseRate->rateCardId);
    }
} catch (OAuth2Exception $e) {
// $path = '/path/to/dfp_api_php_lib/src';
$path = dirname(__FILE__) . '/../../../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201502/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the ContactService.
    $contactService = $user->GetService('ContactService', 'v201502');
    // Create a statement to select only contacts that aren't invited yet.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('status = :status')->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT)->WithBindVariableValue('status', 'UNINVITED');
    // Default for total result set size.
    $totalResultSetSize = 0;
    do {
        // Get contacts by statement.
        $page = $contactService->getContactsByStatement($statementBuilder->ToStatement());
        // Display results.
        if (isset($page->results)) {
            $totalResultSetSize = $page->totalResultSetSize;
            $i = $page->startIndex;
            foreach ($page->results as $contact) {
                printf("%d) Contact with ID %d, and name '%s' was found.\n", $i++, $contact->id, $contact->name);
            }
        }
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
/**
 * Gets predefined custom targeting key IDs.
 */
function getPredefinedCustomTargetingKeyIds($user)
{
    $customTargetingKeyIds = array();
    // Get the CustomTargetingService.
    $customTargetingService = $user->GetService('CustomTargetingService', 'v201508');
    // Create a statement to get predefined custom targeting keys.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('type = :type')->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT)->WithBindVariableValue('type', 'PREDEFINED');
    // Default for total result set size.
    $totalResultSetSize = 0;
    do {
        // Get custom targeting keys by statement.
        $page = $customTargetingService->getCustomTargetingKeysByStatement($statementBuilder->ToStatement());
        // Display results.
        if (isset($page->results)) {
            $totalResultSetSize = $page->totalResultSetSize;
            $i = $page->startIndex;
            foreach ($page->results as $customTargetingKey) {
                printf("%d) Custom targeting key with ID %d, name '%s', and display " . "name '%s' was found.\n", $i++, $customTargetingKey->id, $customTargetingKey->name, $customTargetingKey->displayName);
                $customTargetingKeyIds[] = $customTargetingKey->id;
            }
        }
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
    } while ($statementBuilder->GetOffset() < $totalResultSetSize);
    return $customTargetingKeyIds;
}
예제 #15
0
require_once 'Google/Api/Ads/Dfp/Util/v201505/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the ID of the activity group to update.
$activityGroupId = 'INSERT_ACTIVITY_GROUP_ID_HERE';
// Set the ID of the company to associate with the activity group.
$advertiserCompanyId = 'INSERT_ADVERTISER_COMPANY_ID_HERE';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the ActivityGroupService.
    $activityGroupService = $user->GetService('ActivityGroupService', 'v201505');
    // Create a statement to select a single activity group by ID.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('id = :id')->OrderBy('id ASC')->Limit(1)->WithBindVariableValue('id', $activityGroupId);
    // Get the activity group.
    $page = $activityGroupService->getActivityGroupsByStatement($statementBuilder->ToStatement());
    $activityGroup = $page->results[0];
    // Update the companies.
    $activityGroup->companyIds[] = $advertiserCompanyId;
    // Update the activity group on the server.
    $activityGroups = $activityGroupService->updateActivityGroups(array($activityGroup));
    foreach ($activityGroups as $updatedActivityGroup) {
        printf("Activity group with ID %d, and name '%s' was updated.\n", $updatedActivityGroup->id, $updatedActivityGroup->name);
    }
} catch (OAuth2Exception $e) {
    ExampleUtils::CheckForOAuth2Errors($e);
} catch (ValidationException $e) {
    ExampleUtils::CheckForOAuth2Errors($e);
// $path = '/path/to/dfp_api_php_lib/src';
$path = dirname(__FILE__) . '/../../../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201411/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the LineItemService.
    $lineItemService = $user->GetService('LineItemService', 'v201411');
    // Create a statement to select only recently updated line items.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('lastModifiedDateTime >= :lastModifiedDateTime')->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT)->WithBindVariableValue('lastModifiedDateTime', date(DateTimeUtils::$DFP_DATE_TIME_STRING_FORMAT, strtotime('-1 day')));
    // Default for total result set size.
    $totalResultSetSize = 0;
    do {
        // Get line items by statement.
        $page = $lineItemService->getLineItemsByStatement($statementBuilder->ToStatement());
        // Display results.
        if (isset($page->results)) {
            $totalResultSetSize = $page->totalResultSetSize;
            $i = $page->startIndex;
            foreach ($page->results as $lineItem) {
                printf("%d) Line item with ID %d, belonging to order %d, and name '%s' " . "was found.\n", $i++, $lineItem->id, $lineItem->orderId, $lineItem->name);
            }
        }
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201502/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the ID of the proposal to update.
$proposalId = 'INSERT_PROPOSAL_ID_HERE';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the ProposalService.
    $proposalService = $user->GetService('ProposalService', 'v201502');
    // Create a statement to select a single proposal by ID.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('id = :id')->OrderBy('id ASC')->Limit(1)->WithBindVariableValue('id', $proposalId);
    // Get the proposal.
    $page = $proposalService->getProposalsByStatement($statementBuilder->ToStatement());
    $proposal = $page->results[0];
    // Update the proposal's notes.
    $proposal->notes = 'Proposal needs further review before approval.';
    // Update the proposal on the server.
    $proposals = $proposalService->updateProposals(array($proposal));
    foreach ($proposals as $updatedProposal) {
        printf("Proposal with ID %d and name '%s' was updated.\n", $updatedProposal->id, $updatedProposal->name);
    }
} catch (OAuth2Exception $e) {
    ExampleUtils::CheckForOAuth2Errors($e);
} catch (ValidationException $e) {
    ExampleUtils::CheckForOAuth2Errors($e);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201508/Pql.php';
require_once 'Google/Api/Ads/Dfp/Util/v201508/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the PublisherQueryLanguageService.
    $pqlService = $user->GetService('PublisherQueryLanguageService', 'v201508');
    // Set the type of geo target.
    $geoTargetType = 'City';
    // Create statement to select all line items.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Select('Id, Name, CanonicalParentId, ParentIds, CountryCode, Type, Targetable')->From('Geo_Target')->Where('Type = :Type AND Targetable = true')->OrderBy('CountryCode ASC, Name ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT)->WithBindVariableValue('Type', $geoTargetType);
    // Default for result sets.
    $resultSet = null;
    $combinedResultSet = null;
    $i = 0;
    do {
        // Get all cities.
        $resultSet = $pqlService->select($statementBuilder->ToStatement());
        // Combine result sets with previous ones.
        $combinedResultSet = !isset($combinedResultSet) ? $resultSet : Pql::CombineResultSets($combinedResultSet, $resultSet);
        printf("%d) %d geo targets beginning at offset %d were found.\n", $i++, isset($resultSet->rows) ? count($resultSet->rows) : 0, $statementBuilder->GetOffset());
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
    } while (isset($resultSet->rows) && count($resultSet->rows) > 0);
    // Change to your file location.
    $filePath = sprintf("%s/%s-%s.csv", sys_get_temp_dir(), $geoTargetType, uniqid());
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201408/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the email address of the user to select.
$emailAddress = 'INSERT_EMAIL_ADDRESS_HERE';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the UserService.
    $userService = $user->GetService('UserService', 'v201408');
    // Create a statement to select users by email.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('email = :email')->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT)->WithBindVariableValue('email', $emailAddress);
    // Default for total result set size.
    $totalResultSetSize = 0;
    do {
        // Get users by statement.
        $page = $userService->getUsersByStatement($statementBuilder->ToStatement());
        // Display results.
        if (isset($page->results)) {
            $totalResultSetSize = $page->totalResultSetSize;
            $i = $page->startIndex;
            foreach ($page->results as $user) {
                printf("%d) User with ID %d, email '%s', and role '%s' was found.\n", $i++, $user->id, $user->email, $user->roleName);
            }
        }
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
예제 #20
0
// $path = '/path/to/dfp_api_php_lib/src';
$path = dirname(__FILE__) . '/../../../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201602/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the LineItemCreativeAssociationService.
    $licaService = $user->GetService('LineItemCreativeAssociationService', 'v201602');
    // Create a statement to select all LICAs.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->OrderBy('lineItemId ASC, creativeId ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    $totalResultSetSize = 0;
    do {
        // Get LICAs by statement.
        $page = $licaService->getLineItemCreativeAssociationsByStatement($statementBuilder->ToStatement());
        // Display results.
        if (isset($page->results)) {
            $totalResultSetSize = $page->totalResultSetSize;
            $i = $page->startIndex;
            foreach ($page->results as $lica) {
                if (isset($lica->creativeSetId)) {
                    printf("%d) LICA with line item ID %d, and creative set ID %d was " . "found.\n", $i++, $lica->lineItemId, $lica->creativeSetId);
                } else {
                    printf("%d) LICA with line item ID %d, and creative ID %d was " . "found.\n", $i++, $lica->lineItemId, $lica->creativeId);
$path = dirname(__FILE__) . '/../../../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201508/Pql.php';
require_once 'Google/Api/Ads/Dfp/Util/v201508/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the PublisherQueryLanguageService.
    $pqlService = $user->GetService('PublisherQueryLanguageService', 'v201508');
    // Create statement to select all line items.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Select('Id, BrowserName, MajorVersion, MinorVersion')->From('Browser')->OrderBy('BrowserName ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT);
    // Default for result sets.
    $resultSet = null;
    $combinedResultSet = null;
    $i = 0;
    do {
        // Get all browsers.
        $resultSet = $pqlService->select($statementBuilder->ToStatement());
        // Combine result sets with previous ones.
        $combinedResultSet = !isset($combinedResultSet) ? $resultSet : Pql::CombineResultSets($combinedResultSet, $resultSet);
        printf("%d) %d browsers beginning at offset %d were found.\n", $i++, isset($resultSet->rows) ? count($resultSet->rows) : 0, $statementBuilder->GetOffset());
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
    } while (isset($resultSet->rows) && count($resultSet->rows) > 0);
    // Change to your file location.
    $filePath = sprintf("%s/Browsers-%s.csv", sys_get_temp_dir(), uniqid());
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201508/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the ID of the master creative to get all creative sets for.
$masterCreativeId = "INSERT_MASTER_CREATIVE_ID_HERE";
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the CreativeSetService.
    $creativeSetService = $user->GetService('CreativeSetService', 'v201508');
    // Create a statement to select only creative sets that have the given master
    // creative.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('masterCreativeId = :masterCreativeId')->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT)->WithBindVariableValue('masterCreativeId', $masterCreativeId);
    // Default for total result set size.
    $totalResultSetSize = 0;
    do {
        // Get creative sets by statement.
        $page = $creativeSetService->getCreativeSetsByStatement($statementBuilder->ToStatement());
        // Display results.
        if (isset($page->results)) {
            $totalResultSetSize = $page->totalResultSetSize;
            $i = $page->startIndex;
            foreach ($page->results as $creativeSet) {
                printf("%d) Creative set with ID %d, and name '%s' was found.\n", $i++, $creativeSet->id, $creativeSet->name);
            }
        }
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201505/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the ID of the creative wrapper to update.
$creativeWrapperId = 'INSERT_CREATIVE_WRAPPER_ID_HERE';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the CreativeWrapperService.
    $creativeWrapperService = $user->GetService('CreativeWrapperService', 'v201505');
    // Create a statement to select a single creative wrapper by ID.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('id = :id')->OrderBy('id ASC')->Limit(1)->WithBindVariableValue('id', $creativeWrapperId);
    // Get the creative wrapper.
    $page = $creativeWrapperService->getCreativeWrappersByStatement($statementBuilder->ToStatement());
    $creativeWrapper = $page->results[0];
    // Update the creative wrapper ordering.
    $creativeWrapper->ordering = 'OUTER';
    // Update the creative wrapper on the server.
    $creativeWrappers = $creativeWrapperService->updateCreativeWrappers(array($creativeWrapper));
    foreach ($creativeWrappers as $updatedCreativeWrapper) {
        printf("Creative wrapper with ID %d, and wrapping order '%s' was " . "updated.\n", $updatedCreativeWrapper->id, $updatedCreativeWrapper->ordering);
    }
} catch (OAuth2Exception $e) {
    ExampleUtils::CheckForOAuth2Errors($e);
} catch (ValidationException $e) {
    ExampleUtils::CheckForOAuth2Errors($e);
// $path = '/path/to/dfp_api_php_lib/src';
$path = dirname(__FILE__) . '/../../../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201508/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the AudienceSegmentService.
    $audienceSegmentService = $user->GetService('AudienceSegmentService', 'v201508');
    // Create a statement to select only first party audience segments.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('type = :type')->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT)->WithBindVariableValue('type', 'FIRST_PARTY');
    // Default for total result set size.
    $totalResultSetSize = 0;
    do {
        // Get audience segments by statement.
        $page = $audienceSegmentService->getAudienceSegmentsByStatement($statementBuilder->ToStatement());
        // Display results.
        if (isset($page->results)) {
            $totalResultSetSize = $page->totalResultSetSize;
            $i = $page->startIndex;
            foreach ($page->results as $audienceSegment) {
                printf("%d) Audience segment with ID %d, name '%s', and size %s was " . "found.\n", $i++, $audienceSegment->id, $audienceSegment->name, $audienceSegment->size);
            }
        }
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201602/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the ID of the proposal to submit for approval.
$proposalId = 'INSERT_PROPOSAL_ID_HERE';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the ProposalService.
    $proposalService = $user->GetService('ProposalService', 'v201602');
    // Create a statement to select a single proposal by ID.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('id = :id')->OrderBy('id ASC')->Limit(1)->WithBindVariableValue('id', $proposalId);
    // Default for total result set size.
    $totalResultSetSize = 0;
    do {
        // Get proposals by statement.
        $page = $proposalService->getProposalsByStatement($statementBuilder->ToStatement());
        // Display results.
        if (isset($page->results)) {
            $totalResultSetSize = $page->totalResultSetSize;
            $i = $page->startIndex;
            foreach ($page->results as $proposal) {
                printf("%d) Proposal with ID %d and name '%s' will be submitted for " . "approval.\n", $i++, $proposal->id, $proposal->name);
            }
        }
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
예제 #26
0
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201602/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the ad unit ID to archive underneath.
$parentAdUnitId = 'INSERT_AD_UNIT_ID_HERE';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the InventoryService.
    $inventoryService = $user->GetService('InventoryService', 'v201602');
    // Create a statement to select ad units under the parent ad unit and the
    // parent ad unit.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('parentId = :parentId or id = :parentId')->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT)->WithBindVariableValue('parentId', $parentAdUnitId);
    // Default for total result set size.
    $totalResultSetSize = 0;
    do {
        // Get ad units by statement.
        $page = $inventoryService->getAdUnitsByStatement($statementBuilder->ToStatement());
        // Display results.
        if (isset($page->results)) {
            $totalResultSetSize = $page->totalResultSetSize;
            $i = $page->startIndex;
            foreach ($page->results as $adUnit) {
                printf("%d) Ad unit with ID %d, and name '%s' will be archived.\n", $i++, $adUnit->id, $adUnit->name);
            }
        }
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201608/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the ID of the custom targeting key to update.
$customTargetingKeyId = 'INSERT_CUSTOM_TARGETING_KEY_ID_HERE';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the CustomTargetingService.
    $customTargetingService = $user->GetService('CustomTargetingService', 'v201608');
    // Create a statement to select a single custom targeting key by ID.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('id = :id')->OrderBy('id ASC')->Limit(1)->WithBindVariableValue('id', $customTargetingKeyId);
    // Default for total result set size.
    $totalResultSetSize = 0;
    // Get the custom targeting key.
    $page = $customTargetingService->getCustomTargetingKeysByStatement($statementBuilder->ToStatement());
    $customTargetingKey = $page->results[0];
    // Update the custom targeting key's display name.
    $customTargetingKey->displayName = 'New custom targeting key display name.';
    // Update the custom targeting key on the server.
    $customTargetingKeys = $customTargetingService->updateCustomTargetingKeys(array($customTargetingKey));
    foreach ($customTargetingKeys as $updatedCustomTargetingKey) {
        printf("Custom targeting key with ID %d, name '%s', and display name '%s' " . "was updated.\n", $updatedCustomTargetingKey->id, $updatedCustomTargetingKey->name, $updatedCustomTargetingKey->displayName);
    }
} catch (OAuth2Exception $e) {
    ExampleUtils::CheckForOAuth2Errors($e);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201505/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
// Set the number of requests for suggested ad units greater than which to
// fetch.
$numRequests = "INSERT_NUMBER_OF_REQUESTS_HERE";
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the SuggestedAdUnitService.
    $suggestedAdUnitService = $user->GetService('SuggestedAdUnitService', 'v201505');
    // Create a statement to select only highly requested suggested ad units.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('numRequests >= :numRequests')->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT)->WithBindVariableValue('numRequests', $numRequests);
    // Default for total result set size.
    $totalResultSetSize = 0;
    do {
        // Get suggested ad units by statement.
        $page = $suggestedAdUnitService->getSuggestedAdUnitsByStatement($statementBuilder->ToStatement());
        // Display results.
        if (isset($page->results)) {
            $totalResultSetSize = $page->totalResultSetSize;
            $i = $page->startIndex;
            foreach ($page->results as $suggestedAdUnit) {
                printf("%d) Suggested ad unit with ID %s, and number of requests %d " . "was found.\n", $i++, $suggestedAdUnit->id, $suggestedAdUnit->numRequests);
            }
        }
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
예제 #29
0
// $path = '/path/to/dfp_api_php_lib/src';
$path = dirname(__FILE__) . '/../../../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Dfp/Util/v201408/StatementBuilder.php';
require_once dirname(__FILE__) . '/../../../Common/ExampleUtils.php';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the ContentService.
    $contentService = $user->GetService('ContentService', 'v201408');
    // Create a statement to select all content.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    $totalResultSetSize = 0;
    do {
        // Get content by statement.
        $page = $contentService->getContentByStatement($statementBuilder->ToStatement());
        // Display results.
        if (isset($page->results)) {
            $totalResultSetSize = $page->totalResultSetSize;
            $i = $page->startIndex;
            foreach ($page->results as $content) {
                printf("%d) Content with ID %d, name '%s', and status %s was found.\n", $i++, $content->id, $content->name, $content->status);
            }
        }
        $statementBuilder->IncreaseOffsetBy(StatementBuilder::SUGGESTED_PAGE_LIMIT);
예제 #30
0
$orderId = 'INSERT_ORDER_ID_HERE';
try {
    // Get DfpUser from credentials in "../auth.ini"
    // relative to the DfpUser.php file's directory.
    $user = new DfpUser();
    // Log SOAP XML request and response.
    $user->LogDefaults();
    // Get the ReportService.
    $reportService = $user->GetService('ReportService', 'v201411');
    // Create report query.
    $reportQuery = new ReportQuery();
    $reportQuery->dimensions = array('ORDER_ID', 'ORDER_NAME');
    $reportQuery->dimensionAttributes = array('ORDER_TRAFFICKER', 'ORDER_START_DATE_TIME', 'ORDER_END_DATE_TIME');
    $reportQuery->columns = array('AD_SERVER_IMPRESSIONS', 'AD_SERVER_CLICKS', 'AD_SERVER_CTR', 'AD_SERVER_CPM_AND_CPC_REVENUE', 'AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM');
    // Create statement to filter for an order.
    $statementBuilder = new StatementBuilder();
    $statementBuilder->Where('order_id = :orderId')->WithBindVariableValue('orderId', $orderId);
    // Set the filter statement.
    $reportQuery->statement = $statementBuilder->ToStatement();
    // Set the start and end dates or choose a dynamic date range type.
    $reportQuery->dateRangeType = 'LAST_MONTH';
    // Create report job.
    $reportJob = new ReportJob();
    $reportJob->reportQuery = $reportQuery;
    // Run report job.
    $reportJob = $reportService->runReportJob($reportJob);
    // Create report downloader.
    $reportDownloader = new ReportDownloader($reportService, $reportJob->id);
    // Wait for the report to be ready.
    $reportDownloader->waitForReportReady();
    // Change to your file location.