/** * Run an example using the $user object. * @param string $user the user that contains the client ID and secret */ function RunExample(DfpUser $user) { // Get the NetworkService. $networkService = $user->GetService('NetworkService'); // Gets the current network. $network = $networkService->getCurrentNetwork(); printf("Current network has network code %d and display name \"%s\".\n", $network->networkCode, $network->displayName); }
/** * Finds the root ad unit for the user. * @param DfpUser $user the user to get the root ad unit for * @return the ad unit representing the root ad unit or <var>NULL</var> if one * is not found. * @access private */ function FindRootAdUnit(DfpUser $user) { // Get the InventoryService. $inventoryService = $user->GetService('InventoryService', 'v201208'); // Create a statement to only select image creatives. $filterStatement = new Statement("WHERE parentId IS NULL LIMIT 1"); // Get ad units by statement. $page = $inventoryService->getAdUnitsByStatement($filterStatement); if (isset($page->results)) { return $page->results[0]; } else { return NULL; } }
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 * @author Paul Rashidi */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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 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 CustomFieldService. $customFieldService = $user->GetService('CustomFieldService', 'v201211'); // Set the ID of the drop-down custom field to create options for. $customFieldId = "INSERT_DROP_DOWN_CUSTOM_FIELD_ID_HERE"; // Create custom field options. $customFieldOption1 = new CustomFieldOption(); $customFieldOption1->displayName = 'Approved'; $customFieldOption1->customFieldId = $customFieldId; $customFieldOption2 = new CustomFieldOption(); $customFieldOption2->displayName = 'Unapproved'; $customFieldOption2->customFieldId = $customFieldId; // Create the custom targeting keys on the server. $customFieldOptions = $customFieldService->createCustomFieldOptions(array($customFieldOption1, $customFieldOption2));
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 * @author Adam Rogal <*****@*****.**> * @author Eric Koleda <*****@*****.**> */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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'; 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', 'v201108'); // Create a statement to get all ad units. $filterStatement = new Statement("LIMIT 500"); // Get ad units by statement. $page = $inventoryService->getAdUnitsByStatement($filterStatement); if (isset($page->results)) { $adUnits = $page->results; // Update each local ad unit object by enabling AdSense. foreach ($adUnits as $adUnit) { $adUnit->inheritedAdSenseSettings->value->adSenseEnabled = TRUE; } // Update the ad units on the server.
* Version 2.0 * @author Paul Rashidi */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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 dirname(__FILE__) . '/../../../Common/ExampleUtils.php'; require_once 'Google/Api/Ads/Common/Util/MapUtils.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 CustomFieldService. $customFieldService = $user->GetService('CustomFieldService', 'v201308'); // Get the LineItemService. $lineItemService = $user->GetService('LineItemService', 'v201308'); // Set the IDs of the custom fields, custom field option, and line item. $customFieldId = "INSERT_CUSTOM_FIELD_ID_HERE"; $dropDownCustomFieldId = "INSERT_DROP_DOWN_CUSTOM_FIELD_ID_HERE"; $customFieldOptionId = "INSERT_CUSTOM_FIELD_OPTION_ID_HERE"; $lineItemId = "INSERT_LINE_ITEM_ID_HERE"; // Get the line item. $lineItem = $lineItemService->getLineItem($lineItemId); // Create custom field values. $customFieldValues = array();
* Version 2.0 * @author Eric Koleda * @author Paul Rashidi */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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 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 LabelService. $labelService = $user->GetService('LabelService', 'v201405'); // Create statement text to get all active labels. $filterStatementText = "WHERE isActive = true"; $offset = 0; do { // Create statement to page through results. $filterStatement = new Statement($filterStatementText . " LIMIT 500 OFFSET " . $offset); // Get labels by statement. $page = $labelService->getLabelsByStatement($filterStatement); // Display results. $labelIds = array(); if (isset($page->results)) {
*/ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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/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.
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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/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 CreativeService. $creativeService = $user->GetService('CreativeService', 'v201602'); // Create a statement to select all creatives. $statementBuilder = new StatementBuilder(); $statementBuilder->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT); // Default for total result set size. $totalResultSetSize = 0; do { // Get creatives by statement. $page = $creativeService->getCreativesByStatement($statementBuilder->ToStatement()); // Display results. if (isset($page->results)) { $totalResultSetSize = $page->totalResultSetSize;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 * @author Eric Koleda */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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 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 SuggestedAdUnitService. $suggestedAdUnitService = $user->GetService('SuggestedAdUnitService', 'v201405'); // Set defaults for page and statement. $page = new SuggestedAdUnitPage(); $filterStatement = new Statement(); $offset = 0; do { // Create a statement to get all suggested ad units. $filterStatement->query = 'LIMIT 500 OFFSET ' . $offset; // Get creatives by statement. $page = $suggestedAdUnitService->getSuggestedAdUnitsByStatement($filterStatement); // Display results. if (isset($page->results)) {
*/ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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/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) {
*/ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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/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;
* Version 2.0 */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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/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.
*/ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // DfpUser.php directly via require_once. // $path = '/path/to/dfp_api_php_lib/src'; $path = dirname(__FILE__) . '/../../../../lib'; 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;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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/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(); // Get the ReconciliationReportService. $reconciliationReportService = $user->GetService('ReconciliationReportService', 'v201608'); // Create a statement to select reconciliation reports. $statementBuilder = new StatementBuilder(); $statementBuilder->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT); // Default for total result set size. $totalResultSetSize = 0; do { // Get reconciliation reports by statement. $page = $reconciliationReportService->getReconciliationReportsByStatement($statementBuilder->ToStatement()); // Display results. if (isset($page->results)) { $totalResultSetSize = $page->totalResultSetSize;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 * @author Paul Rashidi */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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 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 UserTeamAssociationService. $userTeamAssociationService = $user->GetService('UserTeamAssociationService', 'v201311'); // Set the IDs of the user and team to get the association for. $userId = 'INSERT_USER_ID_HERE'; $teamId = 'INSERT_TEAM_ID_HERE'; // Get the user team association. $uta = $userTeamAssociationService->getUserTeamAssociation($teamId, $userId); // Display results. if (isset($uta)) { print 'User team association between user with ID "' . $uta->userId . '" and team with ID "' . $uta->teamId . "\" was found.\n"; } else { print "No user team association found for this ID.\n"; }
* @copyright 2013, Google Inc. All Rights Reserved. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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 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', 'v201411'); // Get the NetworkService. $networkService = $user->GetService('NetworkService', 'v201411'); // Set the IDs of the custom criteria to be used in the segment rule. $customTargetingKeyId = 'INSERT_CUSTOM_TARGETING_KEY_ID_HERE'; $customTargetingValueId = 'INSERT_CUSTOM_TARGETING_VALUE_ID_HERE'; // Get the root ad unit ID used to target the whole site. $rootAdUnitId = $networkService->getCurrentNetwork()->effectiveRootAdUnitId; // Create inventory targeting to be used in the segment rule. $inventoryTargeting = new InventoryTargeting(); // Create ad unit targeting for the root ad unit (i.e. the whole network). $adUnitTargeting = new AdUnitTargeting();
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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/v201505/DateTimeUtils.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 ForecastService. $forecastService = $user->GetService('ForecastService', 'v201505'); // Get the NetworkService. $networkService = $user->GetService('NetworkService', 'v201505'); // Get the root ad unit ID used to target the whole site. $rootAdUnitId = $networkService->getCurrentNetwork()->effectiveRootAdUnitId; // Create inventory targeting. $inventoryTargeting = new InventoryTargeting(); // Create ad unit targeting for the root ad unit. $adUnitTargeting = new AdUnitTargeting(); $adUnitTargeting->adUnitId = $rootAdUnitId; $adUnitTargeting->includeDescendants = true; $inventoryTargeting->targetedAdUnits = array($adUnitTargeting);
* @category WebServices * @copyright 2011, Google Inc. All Rights Reserved. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 * @author Eric Koleda <*****@*****.**> */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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'; 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 OrderService. $orderService = $user->GetOrderService('v201104'); // Create statement text to get all draft or pending approval orders. $filterStatementText = "WHERE status = 'DRAFT' OR status = 'PENDING_APPROVAL'"; $offset = 0; do { // Create statement to page through results. $filterStatement = new Statement($filterStatementText . " LIMIT 500 OFFSET " . $offset); // Get orders by statement. $page = $orderService->getOrdersByStatement($filterStatement); // Display results. $orderIds = array(); if (isset($page->results)) {
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 * @author Vincent Tsao */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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 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', 'v201311'); // Set the ID of the advertiser company this contact is associated with. $advertiserCompanyId = 'INSERT_ADVERTISER_COMPANY_ID_HERE'; // Set the ID of the agency company this contact is associated with. $agencyCompanyId = 'INSERT_AGENCY_COMPANY_ID_HERE'; // Create an advertiser contact. $advertiserContact = new Contact(); $advertiserContact->name = sprintf('Mr. Advertiser #%s', uniqid()); $advertiserContact->email = '*****@*****.**'; $advertiserContact->companyId = $advertiserCompanyId; // Create an agency contact. $agencyContact = new Contact();
*/ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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'; // 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) {
* @copyright 2011, Google Inc. All Rights Reserved. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 * @author Adam Rogal <*****@*****.**> * @author Eric Koleda <*****@*****.**> */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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'; 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->GetCompanyService('v201104'); // Create an array to store local company objects. $companies = array(); for ($i = 0; $i < 5; $i++) { $company = new Company(); $company->name = 'Advertiser #' . $i; $company->type = 'ADVERTISER'; $companies[] = $company; } // Create the companies on the server. $companies = $companyService->createCompanies($companies); // Display results.
* @copyright 2014, Google Inc. All Rights Reserved. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // DfpUser.php directly via require_once. // $path = '/path/to/dfp_api_php_lib/src'; $path = dirname(__FILE__) . '/../../../../lib'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.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 ExchangeRateService. $exchangeRateService = $user->GetService('ExchangeRateService', 'v201411'); // Create an exchange rate. $exchangeRate = new ExchangeRate(); // Set the currency code. $exchangeRate->currencyCode = 'AUD'; // Set the direction of the conversion (from the network currency). $exchangeRate->direction = 'FROM_NETWORK'; // Set the conversion value as 1.5 (this value is multiplied by // 10,000,000,000) $exchangeRate->exchangeRate = 15000000000; // Do not refresh exchange rate from Google data. Update manually only. $exchangeRate->refreshRate = 'FIXED';
*/ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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/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)) {
*/ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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/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;
* Version 2.0 * @author Vincent Tsao */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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/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;
* @copyright 2012, Google Inc. All Rights Reserved. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 * @author Eric Koleda */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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 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 NetworkService. $networkService = $user->GetService('NetworkService', 'v201211'); // Get the current network. $network = $networkService->getCurrentNetwork(); print 'Current network has network code "' . $network->networkCode . '" and display name "' . $network->displayName . "\".\n"; } catch (OAuth2Exception $e) { ExampleUtils::CheckForOAuth2Errors($e); } catch (ValidationException $e) { ExampleUtils::CheckForOAuth2Errors($e); } catch (Exception $e) { print $e->getMessage() . "\n"; }
* @copyright 2013, Google Inc. All Rights Reserved. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 * @author Eric Koleda */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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 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 UserService. $userService = $user->GetService('UserService', 'v201302'); // Get the current user. $usr = $userService->getCurrentUser(); printf("User with ID '%s', email '%s', and role '%s' was found.\n", $usr->id, $usr->email, $usr->roleName); } catch (OAuth2Exception $e) { ExampleUtils::CheckForOAuth2Errors($e); } catch (ValidationException $e) { ExampleUtils::CheckForOAuth2Errors($e); } catch (Exception $e) { print $e->getMessage() . "\n"; }
* @copyright 2013, Google Inc. All Rights Reserved. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // DfpUser.php directly via require_once. // $path = '/path/to/dfp_api_php_lib/src'; $path = dirname(__FILE__) . '/../../../../lib'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.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 ActivityService. $activityService = $user->GetService('ActivityService', 'v201502'); // Set the ID of the activity group this activity is associated with. $activityGroupId = 'INSERT_ACTIVITY_GROUP_ID_HERE'; // Create a daily visits activity. $dailyVisitsActivity = new Activity(); $dailyVisitsActivity->name = sprintf('Activity #%s', uniqid()); $dailyVisitsActivity->activityGroupId = $activityGroupId; $dailyVisitsActivity->type = 'DAILY_VISITS'; // Create a custom activity. $customActivity = new Activity(); $customActivity->name = sprintf('Activity #%s', uniqid()); $customActivity->activityGroupId = $activityGroupId;
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 * @author Paul Rashidi */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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 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 TeamService. $teamService = $user->GetService('TeamService', 'v201408'); // Set defaults for page and statement. $page = new TeamPage(); $filterStatement = new Statement(); $offset = 0; do { // Create a statement to get all teams. $filterStatement->query = 'LIMIT 500 OFFSET ' . $offset; // Get teams by statement. $page = $teamService->getTeamsByStatement($filterStatement); // Display results. if (isset($page->results)) {
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 */ error_reporting(E_STRICT | E_ALL); // You can set the include path to src directory or reference // 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 OrderService. $orderService = $user->GetService('OrderService', 'v201502'); // Create a statement to select all orders. $statementBuilder = new StatementBuilder(); $statementBuilder->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT); // Default for total result set size. $totalResultSetSize = 0; do { // Get orders by statement. $page = $orderService->getOrdersByStatement($statementBuilder->ToStatement()); // Display results. if (isset($page->results)) { $totalResultSetSize = $page->totalResultSetSize;