本文整理匯總了PHP中DfpUser::GetService方法的典型用法代碼示例。如果您正苦於以下問題:PHP DfpUser::GetService方法的具體用法?PHP DfpUser::GetService怎麽用?PHP DfpUser::GetService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DfpUser
的用法示例。
在下文中一共展示了DfpUser::GetService方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: RunExample
/**
* 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);
}
示例2: FindRootAdUnit
/**
* 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;
}
}
示例3: dirname
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));
// Display results.
if (isset($customFieldOptions)) {
foreach ($customFieldOptions as $customFieldOption) {
printf("A custom field option with ID '%s' and name '%s' was created.\n", $customFieldOption->id, $customFieldOption->displayName);
示例4: dirname
*/
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.
$adUnits = $inventoryService->updateAdUnits($adUnits);
// Display results.
if (isset($adUnits)) {
foreach ($adUnits as $adUnit) {
示例5: dirname
// 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();
$customFieldValue = new CustomFieldValue();
$customFieldValue->customFieldId = $customFieldId;
$customFieldValue->value = new TextValue("Custom field value");
$customFieldValues[] = $customFieldValue;
示例6: dirname
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)) {
foreach ($page->results as $label) {
printf("A label with ID '%s' and name '%s' will be deactivated.\n", $label->id, $label->name);
$labelIds[] = $label->id;
}
示例7: dirname
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 = 'advertiser@advertising.com';
$advertiserContact->companyId = $advertiserCompanyId;
// Create an agency contact.
$agencyContact = new Contact();
$agencyContact->name = sprintf('Ms. Agency #%s', uniqid());
$agencyContact->email = 'agency@agencies.com';
$agencyContact->companyId = $agencyCompanyId;
// Create the contacts on the server.
示例8: dirname
* @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 UserService.
$userService = $user->GetService('UserService', 'v201211');
// 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";
}
示例9: dirname
// $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) {
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);
示例10: dirname
// 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/v201511/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 CreativeSetService.
$creativeSetService = $user->GetService('CreativeSetService', 'v201511');
// Create a statement to select all creative sets.
$statementBuilder = new StatementBuilder();
$statementBuilder->OrderBy('id ASC')->Limit(StatementBuilder::SUGGESTED_PAGE_LIMIT);
// 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);
}
示例11: dirname
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)) {
$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);
$i++;
示例12: dirname
// $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) {
printf("Creative wrapper with ID %d, and wrapping order '%s' was " . "updated.\n", $updatedCreativeWrapper->id, $updatedCreativeWrapper->ordering);
}
} catch (OAuth2Exception $e) {
ExampleUtils::CheckForOAuth2Errors($e);
示例13: dirname
// $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;
$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);
}
示例14: dirname
// 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.
$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);
示例15: dirname
// $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;
$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);