本文整理汇总了PHP中AdWordsUser::SetExpressBusinessId方法的典型用法代码示例。如果您正苦于以下问题:PHP AdWordsUser::SetExpressBusinessId方法的具体用法?PHP AdWordsUser::SetExpressBusinessId怎么用?PHP AdWordsUser::SetExpressBusinessId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdWordsUser
的用法示例。
在下文中一共展示了AdWordsUser::SetExpressBusinessId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AddPromotionExample
/**
* Runs the example.
* @param AdWordsUser $user the user to run the example with
*/
function AddPromotionExample(AdWordsUser $user, $businessId)
{
// Get the business service, which loads the required classes.
$businessService = $user->GetService('ExpressBusinessService', ADWORDS_VERSION);
// Get the business for the businessId. We will need its geo point
// to create a Proximity criterion for the new Promotion.
$businessSelector = new Selector();
$businessSelector->fields = array('Id', 'GeoPoint');
$businessPredicate = new Predicate('Id', 'EQUALS', array($businessId));
$businessSelector->predicates = array($businessPredicate);
$businessEntries = $businessService->get($businessSelector)->entries;
$business = $businessEntries[0];
// PromotionService requires the businessId on the user.
$user->SetExpressBusinessId($businessId);
// Get the promotion service.
$promotionService = $user->GetService('PromotionService', ADWORDS_VERSION);
// Set up the new Promotion.
$marsTourPromotion = new Promotion();
$budget = new Money();
$budget->microAmount = 1000000;
$marsTourPromotion->name = 'Mars Tour Promotion ' . uniqid();
$marsTourPromotion->status = 'PAUSED';
$marsTourPromotion->destinationUrl = 'http://www.example.com';
$marsTourPromotion->budget = $budget;
$marsTourPromotion->callTrackingEnabled = true;
// Criteria
$criteria = array();
// Criterion - Travel Agency product service
$productService = new ProductService();
$productService->text = 'Travel Agency';
$criteria[] = $productService;
// Criterion - English language
// The ID can be found in the documentation:
// https://developers.google.com/adwords/api/docs/appendix/languagecodes
$language = new Language();
$language->id = 1000;
$criteria[] = $language;
// Criterion - Within 15 miles
$proximity = new Proximity();
$proximity->geoPoint = $business->geoPoint;
$proximity->radiusDistanceUnits = 'MILES';
$proximity->radiusInUnits = 15;
$criteria[] = $proximity;
$marsTourPromotion->criteria = $criteria;
// Creatives
$creatives = array();
$creative1 = new Creative('Standard Mars Trip', 'Fly coach to Mars', 'Free in-flight pretzels');
$creatives[] = $creative1;
$creative2 = new Creative('Deluxe Mars Trip', 'Fly first class to Mars', 'Unlimited powdered orange drink');
$creatives[] = $creative2;
$marsTourPromotion->creatives = $creatives;
$operations = array();
$operation = new PromotionOperation();
$operation->operand = $marsTourPromotion;
$operation->operator = 'ADD';
$operations[] = $operation;
$result = $promotionService->mutate($operations);
$addedPromotion = $result[0];
printf("Added promotion ID %d with name '%s' to business ID %d\n", $addedPromotion->id, $addedPromotion->name, $businessId);
}
示例2: GetPromotionsExample
/**
* Runs the example.
* @param AdWordsUser $user the user to run the example with
*/
function GetPromotionsExample(AdWordsUser $user, $businessId)
{
$user->SetExpressBusinessId($businessId);
// Get the service, which loads the required classes.
$promotionService = $user->GetService('PromotionService', ADWORDS_VERSION);
// Create selector.
$selector = new Selector();
$selector->fields = array('PromotionId', 'Name');
$selector->ordering[] = new OrderBy('Name', 'ASCENDING');
// Create paging controls.
$selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
// Make the get request.
$page = $promotionService->get($selector);
// Display results.
if (isset($page->entries)) {
foreach ($page->entries as $promotion) {
printf("Express promotion found with name '%s' " . "id %s destinationUrl: %s\n", $promotion->name, $promotion->id, $promotion->destinationUrl);
}
} else {
print "No express promotions were found.\n";
}
// Advance the paging index.
$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
} while ($page->totalNumEntries > $selector->paging->startIndex);
}
示例3: AddPromotionExample
/**
* Runs the example.
* @param AdWordsUser $user the user to run the example with
*/
function AddPromotionExample(AdWordsUser $user, $businessId)
{
// PromotionService requires the businessId on the user.
$user->SetExpressBusinessId($businessId);
// Get the promotion service.
$promotionService = $user->GetService('PromotionService', ADWORDS_VERSION);
// Set up the new Promotion.
$marsTourPromotion = new Promotion();
$budget = new Money();
$budget->microAmount = 1000000;
$marsTourPromotion->name = 'Mars Tour Promotion ' . uniqid();
$marsTourPromotion->status = 'PAUSED';
$marsTourPromotion->destinationUrl = 'http://www.example.com';
$marsTourPromotion->budget = $budget;
$marsTourPromotion->callTrackingEnabled = true;
// Criteria
$criteria = array();
// Criterion - Travel Agency product service
$productService = new ProductService();
$productService->text = 'Travel Agency';
$criteria[] = $productService;
// Criterion - English language
// The ID can be found in the documentation:
// https://developers.google.com/adwords/api/docs/appendix/languagecodes
$language = new Language();
$language->id = 1000;
$criteria[] = $language;
// Criterion - City of California
$location = new Location();
$location->id = 21137;
$criteria[] = $location;
$marsTourPromotion->criteria = $criteria;
// Creatives
$creatives = array();
$creative1 = new Creative('Standard Mars Trip', 'Fly coach to Mars', 'Free in-flight pretzels');
$creatives[] = $creative1;
$creative2 = new Creative('Deluxe Mars Trip', 'Fly first class to Mars', 'Unlimited powdered orange drink');
$creatives[] = $creative2;
$marsTourPromotion->creatives = $creatives;
$operations = array();
$operation = new PromotionOperation();
$operation->operand = $marsTourPromotion;
$operation->operator = 'ADD';
$operations[] = $operation;
$result = $promotionService->mutate($operations);
$addedPromotion = $result[0];
printf("Added promotion ID %d with name '%s' to business ID %d\n", $addedPromotion->id, $addedPromotion->name, $businessId);
}
示例4: UpdatePromotionExample
/**
* Runs the example.
* @param AdWordsUser $user the user to run the example with
*/
function UpdatePromotionExample(AdWordsUser $user, $businessId, $promotionId)
{
// PromotionService requires the businessId on the user.
$user->SetExpressBusinessId($businessId);
// Get the service, which loads the required classes.
$promotionService = $user->GetService('PromotionService', ADWORDS_VERSION);
// Update the budget for the promotion.
$promotion = new Promotion();
$promotion->id = $promotionId;
$newBudget = new Money();
$newBudget->microAmount = 2000000;
$promotion->budget = $newBudget;
$operations = array();
$operation = new PromotionOperation();
$operation->operand = $promotion;
$operation->operator = 'SET';
$operations[] = $operation;
$result = $promotionService->mutate($operations);
$mutatedPromotion = $result[0];
printf("Promotion ID %d for business ID %d now has budget micro amount %d\n", $mutatedPromotion->id, $businessId, $mutatedPromotion->budget->microAmount);
}