• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP AdWordsUser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中AdWordsUser的典型用法代码示例。如果您正苦于以下问题:PHP AdWordsUser类的具体用法?PHP AdWordsUser怎么用?PHP AdWordsUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AdWordsUser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: AddTextAdsExample

function AddTextAdsExample(AdWordsUser $user, $adGroupId)
{
    // Get the service, which loads the required classes.
    $adGroupAdService = $user->GetService('AdGroupAdService', ADWORDS_VERSION);
    $numAds = 5;
    $operations = array();
    for ($i = 0; $i < $numAds; $i++) {
        // Create text ad.
        $textAd = new TextAd();
        $textAd->headline = 'Cruise #' . uniqid();
        $textAd->description1 = 'Visit the Red Planet in style.';
        $textAd->description2 = 'Low-gravity fun for everyone!';
        $textAd->displayUrl = 'www.example.com';
        $textAd->finalUrls = array('http://www.example.com');
        // Create ad group ad.
        $adGroupAd = new AdGroupAd();
        $adGroupAd->adGroupId = $adGroupId;
        $adGroupAd->ad = $textAd;
        // Set additional settings (optional).
        $adGroupAd->status = 'PAUSED';
        // Create operation.
        $operation = new AdGroupAdOperation();
        $operation->operand = $adGroupAd;
        $operation->operator = 'ADD';
        $operations[] = $operation;
    }
    // Make the mutate request.
    $result = $adGroupAdService->mutate($operations);
    // Display results.
    foreach ($result->value as $adGroupAd) {
        printf("Text ad with headline '%s' and ID '%s' was added.\n", $adGroupAd->ad->headline, $adGroupAd->ad->id);
    }
}
开发者ID:a1pro,项目名称:adwords_dashboard,代码行数:33,代码来源:AddTextAds.php


示例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);
}
开发者ID:rochmit10,项目名称:googleads-php-lib,代码行数:30,代码来源:GetPromotions.php


示例3: GetCampaignTargetingCriteriaExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $campaignId the ID of the campaign to get targeting criteria
 *     for
 */
function GetCampaignTargetingCriteriaExample(AdWordsUser $user, $campaignId)
{
    // Get the service, which loads the required classes.
    $campaignCriterionService = $user->GetService('CampaignCriterionService', ADWORDS_VERSION);
    // Create selector.
    $selector = new Selector();
    $selector->fields = array('Id', 'CriteriaType');
    // Create predicates.
    $selector->predicates[] = new Predicate('CampaignId', 'IN', array($campaignId));
    $selector->predicates[] = new Predicate('CriteriaType', 'IN', array('LANGUAGE', 'LOCATION', 'AGE_RANGE', 'CARRIER', 'OPERATING_SYSTEM_VERSION', 'GENDER', 'POLYGON', 'PROXIMITY', 'PLATFORM'));
    // Create paging controls.
    $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
    do {
        // Make the get request.
        $page = $campaignCriterionService->get($selector);
        // Display results.
        if (isset($page->entries)) {
            foreach ($page->entries as $campaignCriterion) {
                printf("Campaign targeting criterion with ID '%s' and type '%s' was " . "found.\n", $campaignCriterion->criterion->id, $campaignCriterion->criterion->CriterionType);
            }
        } else {
            print "No campaign targeting criteria were found.\n";
        }
        // Advance the paging index.
        $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
    } while ($page->totalNumEntries > $selector->paging->startIndex);
}
开发者ID:havardorbech,项目名称:googleads-php-lib,代码行数:33,代码来源:GetCampaignTargetingCriteria.php


示例4: addProductScopeExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param int $campaignId the campaign to modify
 */
function addProductScopeExample(AdWordsUser $user, $campaignId)
{
    // Get the CampaignCriterionService, which loads the required classes.
    $campaignCriterionService = $user->GetService('CampaignCriterionService', ADWORDS_VERSION);
    $productScope = new ProductScope();
    // This set of dimensions is for demonstration purposes only. It would be
    // extremely unlikely that you want to include so many dimensions in your
    // product scope.
    $productScope->dimensions[] = new ProductBrand('Nexus');
    $productScope->dimensions[] = new ProductCanonicalCondition('NEW');
    $productScope->dimensions[] = new ProductCustomAttribute('CUSTOM_ATTRIBUTE_0', 'my attribute value');
    $productScope->dimensions[] = new ProductOfferId('book1');
    $productScope->dimensions[] = new ProductType('PRODUCT_TYPE_L1', 'Media');
    $productScope->dimensions[] = new ProductType('PRODUCT_TYPE_L2', 'Books');
    // The value for the bidding category is a fixed ID for the 'Luggage & Bags'
    // category. You can retrieve IDs for categories from the ConstantDataService.
    // See the 'GetProductCategoryTaxonomy' example for more details.
    $productScope->dimensions[] = new ProductBiddingCategory('BIDDING_CATEGORY_L1', '-5914235892932915235');
    $campaignCriterion = new CampaignCriterion();
    $campaignCriterion->campaignId = $campaignId;
    $campaignCriterion->criterion = $productScope;
    // Create operation.
    $operation = new CampaignCriterionOperation();
    $operation->operand = $campaignCriterion;
    $operation->operator = 'ADD';
    // Make the mutate request.
    $result = $campaignCriterionService->mutate(array($operation));
    printf("Created a ProductScope criterion with ID '%s'", $result->value[0]->criterion->id);
}
开发者ID:rochmit10,项目名称:googleads-php-lib,代码行数:34,代码来源:AddProductScope.php


示例5: DownloadCriteriaReportExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $filePath the path of the file to download the report to
 */
function DownloadCriteriaReportExample(AdWordsUser $user, $filePath)
{
    // Load the service, so that the required classes are available.
    $user->LoadService('ReportDefinitionService', ADWORDS_VERSION);
    // Create selector.
    $selector = new Selector();
    $selector->fields = array('CampaignId', 'AdGroupId', 'Id', 'Criteria', 'CriteriaType', 'Impressions', 'Clicks', 'Cost');
    // Optional: use predicate to filter out paused criteria.
    $selector->predicates[] = new Predicate('Status', 'NOT_IN', array('PAUSED'));
    // Create report definition.
    $reportDefinition = new ReportDefinition();
    $reportDefinition->selector = $selector;
    $reportDefinition->reportName = 'Criteria performance report #' . uniqid();
    $reportDefinition->dateRangeType = 'LAST_7_DAYS';
    $reportDefinition->reportType = 'CRITERIA_PERFORMANCE_REPORT';
    $reportDefinition->downloadFormat = 'CSV';
    // Exclude criteria that haven't recieved any impressions over the date range.
    $reportDefinition->includeZeroImpressions = false;
    // Set additional options.
    $options = array('version' => ADWORDS_VERSION);
    // Optional: Set skipReportHeader, skipColumnHeader, skipReportSummary to
    //     suppress headers or summary rows.
    // $options['skipReportHeader'] = true;
    // $options['skipColumnHeader'] = true;
    // $options['skipReportSummary'] = true;
    // Optional: Set includeZeroImpressions to include zero impression rows in
    //     the report output.
    // $options['includeZeroImpressions'] = true;
    // Download report.
    ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options);
    printf("Report with name '%s' was downloaded to '%s'.\n", $reportDefinition->reportName, $filePath);
}
开发者ID:havardorbech,项目名称:googleads-php-lib,代码行数:37,代码来源:DownloadCriteriaReport.php


示例6: GetTextAdsExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $adGroupId the id of the parent ad group
 */
function GetTextAdsExample(AdWordsUser $user, $adGroupId)
{
    // Get the service, which loads the required classes.
    $adGroupAdService = $user->GetService('AdGroupAdService', ADWORDS_VERSION);
    // Create selector.
    $selector = new Selector();
    $selector->fields = array('Headline', 'Id');
    $selector->ordering[] = new OrderBy('Headline', 'ASCENDING');
    // Create predicates.
    $selector->predicates[] = new Predicate('AdGroupId', 'IN', array($adGroupId));
    $selector->predicates[] = new Predicate('AdType', 'IN', array('TEXT_AD'));
    // By default disabled ads aren't returned by the selector. To return them
    // include the DISABLED status in a predicate.
    $selector->predicates[] = new Predicate('Status', 'IN', array('ENABLED', 'PAUSED', 'DISABLED'));
    // Create paging controls.
    $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
    do {
        // Make the get request.
        $page = $adGroupAdService->get($selector);
        // Display results.
        if (isset($page->entries)) {
            foreach ($page->entries as $adGroupAd) {
                printf("Text ad with headline '%s' and ID '%s' was found.\n", $adGroupAd->ad->headline, $adGroupAd->ad->id);
            }
        } else {
            print "No text ads were found.\n";
        }
        // Advance the paging index.
        $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
    } while ($page->totalNumEntries > $selector->paging->startIndex);
}
开发者ID:googleads,项目名称:googleads-php-lib,代码行数:36,代码来源:GetTextAds.php


示例7: GetExpressBusinessesExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 */
function GetExpressBusinessesExample(AdWordsUser $user)
{
    // Get the service, which loads the required classes.
    $businessService = $user->GetService('ExpressBusinessService', ADWORDS_VERSION);
    // Create selector.
    $selector = new Selector();
    $selector->fields = array('Id', 'Name', 'Website', 'Address', 'GeoPoint', 'Status');
    $selector->ordering[] = new OrderBy('Name', 'ASCENDING');
    // Create paging controls.
    $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
    do {
        // Make the get request.
        $page = $businessService->get($selector);
        // Display results.
        if (isset($page->entries)) {
            foreach ($page->entries as $business) {
                $address = $business->address !== NULL ? $business->address : new Address();
                $geoPoint = $business->geoPoint;
                printf("Express business found with name '%s' id %s website: %s " . "address: %s,%s,%s,%s,%s geo point: %d,%d status: %s\n", $business->name, $business->id, $business->website, $address->streetAddress, $address->streetAddress2, $address->cityName, $address->provinceName, $address->postalCode, $geoPoint->latitudeInMicroDegrees, $geoPoint->longitudeInMicroDegrees, $business->status);
            }
        } else {
            print "No express businesses were found.\n";
        }
        // Advance the paging index.
        $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
    } while ($page->totalNumEntries > $selector->paging->startIndex);
}
开发者ID:rochmit10,项目名称:googleads-php-lib,代码行数:31,代码来源:GetExpressBusinesses.php


示例8: AddConversionTrackerExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 */
function AddConversionTrackerExample(AdWordsUser $user)
{
    // Get the service, which loads the required classes.
    $conversionTrackerService = $user->GetService('ConversionTrackerService', ADWORDS_VERSION);
    // Create conversion tracker.
    $conversionTracker = new AdWordsConversionTracker();
    $conversionTracker->name = 'Interplanetary Cruise Conversion #' . uniqid();
    // Set additional settings (optional).
    $conversionTracker->status = 'ENABLED';
    $conversionTracker->category = 'DEFAULT';
    $conversionTracker->viewthroughLookbackWindow = 15;
    $conversionTracker->isProductAdsChargeable = TRUE;
    $conversionTracker->productAdsChargeableConversionWindow = 15;
    $conversionTracker->markupLanguage = 'HTML';
    $conversionTracker->textFormat = 'HIDDEN';
    $conversionTracker->conversionPageLanguage = 'en';
    $conversionTracker->backgroundColor = '#0000FF';
    // Create operation.
    $operation = new ConversionTrackerOperation();
    $operation->operand = $conversionTracker;
    $operation->operator = 'ADD';
    $operations = array($operation);
    // Make the mutate request.
    $result = $conversionTrackerService->mutate($operations);
    // Display result.
    $conversionTracker = $result->value[0];
    printf("Conversion type with name '%s' and ID '%.0f' was added.\n", $conversionTracker->name, $conversionTracker->id);
    printf("Tag code:\n%s\n", $conversionTracker->snippet);
}
开发者ID:rochmit10,项目名称:googleads-php-lib,代码行数:33,代码来源:AddConversionTracker.php


示例9: LookupLocationExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 */
function LookupLocationExample(AdWordsUser $user)
{
    // Get the service, which loads the required classes.
    $locationCriterionService = $user->GetService('LocationCriterionService', 'v201109');
    // Location names to look up.
    $locationNames = array('Paris', 'Quebec', 'Spain', 'Deutschland');
    // Locale to retrieve location names in.
    $locale = 'en';
    $selector = new Selector();
    $selector->fields = array('Id', 'LocationName', 'CanonicalName', 'DisplayType', 'ParentLocations', 'Reach');
    // Location names must match exactly, only EQUALS and IN are supported.
    $selector->predicates[] = new Predicate('LocationName', 'IN', $locationNames);
    // Only one locale can be used in a request.
    $selector->predicates[] = new Predicate('Locale', 'EQUALS', $locale);
    // Make the get request.
    $locationCriteria = $locationCriterionService->get($selector);
    // Display results.
    if (isset($locationCriteria)) {
        foreach ($locationCriteria as $locationCriterion) {
            if (isset($locationCriterion->location->parentLocations)) {
                $parentLocations = implode(', ', array_map('GetLocationString', $locationCriterion->location->parentLocations));
            } else {
                $parentLocations = 'N/A';
            }
            printf("The search term '%s' returned the location '%s' of type '%s' " . "with ID '%s', parent locations '%s', and reach '%d'.\n", $locationCriterion->searchTerm, $locationCriterion->location->locationName, $locationCriterion->location->displayType, $locationCriterion->location->id, $parentLocations, $locationCriterion->reach);
        }
    } else {
        print "No location criteria were found.\n";
    }
}
开发者ID:sambavade,项目名称:google-api-adwords-php,代码行数:34,代码来源:LookupLocation.php


示例10: GetCampaignStatsExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $campaignId the ID of the campaign to get stats for
 */
function GetCampaignStatsExample(AdWordsUser $user)
{
    // Get the service, which loads the required classes.
    $campaignService = $user->GetService('CampaignService', ADWORDS_VERSION);
    // Create selector.
    $selector = new Selector();
    $selector->fields = array('Id', 'Name', 'Impressions', 'Clicks', 'Cost', 'Ctr');
    $selector->predicates[] = new Predicate('Impressions', 'GREATER_THAN', array(0));
    // Set date range to request stats for.
    $dateRange = new DateRange();
    $dateRange->min = date('Ymd', strtotime('-1 week'));
    $dateRange->max = date('Ymd', strtotime('-1 day'));
    $selector->dateRange = $dateRange;
    // Create paging controls.
    $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
    do {
        // Make the get request.
        $page = $campaignService->get($selector);
        // Display results.
        if (isset($page->entries)) {
            foreach ($page->entries as $campaign) {
                printf("Campaign with name '%s' and id '%s' had the following stats " . "during the last week:\n", $campaign->name, $campaign->id);
                printf("  Impressions: %d\n", $campaign->campaignStats->impressions);
                printf("  Clicks: %d\n", $campaign->campaignStats->clicks);
                printf("  Cost: \$%.2f\n", $campaign->campaignStats->cost->microAmount / AdWordsConstants::MICROS_PER_DOLLAR);
                printf("  CTR: %.2f%%\n", $campaign->campaignStats->ctr * 100);
            }
        } else {
            print "No matching campaigns were found.\n";
        }
        // Advance the paging index.
        $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
    } while ($page->totalNumEntries > $selector->paging->startIndex);
}
开发者ID:sambavade,项目名称:google-api-adwords-php,代码行数:39,代码来源:GetCampaignStats.php


示例11: GetCampaignsByLabelExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $labelId the label id to run the example with
 */
function GetCampaignsByLabelExample(AdWordsUser $user, $labelId)
{
    // Get the service, which loads the required classes.
    $campaignService = $user->GetService('CampaignService', ADWORDS_VERSION);
    // Create selector.
    $selector = new Selector();
    $selector->fields = array('Id', 'Name', 'Labels');
    // Labels filtering is performed by ID. You can use containsAny to select
    // campaigns with any of the label IDs, containsAll to select campaigns with
    // all of the label IDs, or containsNone to select campaigns with none of the
    // label IDs.
    $selector->predicates[] = new Predicate('Labels', 'CONTAINS_ANY', array($labelId));
    $selector->ordering[] = new OrderBy('Name', 'ASCENDING');
    // Create paging controls.
    $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
    do {
        // Make the get request.
        $page = $campaignService->get($selector);
        // Display results.
        if (isset($page->entries)) {
            foreach ($page->entries as $campaign) {
                printf("Campaign with name '%s' and ID '%d' and labels '%s'" . " was found.\n", $campaign->name, $campaign->id, implode(', ', array_map(function ($label) {
                    return sprintf('%d/%s', $label->id, $label->name);
                }, $campaign->labels)));
            }
        } else {
            print "No campaigns were found.\n";
        }
        // Advance the paging index.
        $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
    } while ($page->totalNumEntries > $selector->paging->startIndex);
}
开发者ID:planetfitnessnational,项目名称:googleads-php-lib,代码行数:37,代码来源:GetCampaignsByLabel.php


示例12: UploadOfflineConversionsExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $campaignId the ID of the campaign to add the sitelinks to
 */
function UploadOfflineConversionsExample(AdWordsUser $user, $conversionName, $gClId, $conversionTime, $conversionValue)
{
    // Get the services, which loads the required classes.
    $conversionTrackerService = $user->GetService('ConversionTrackerService', ADWORDS_VERSION);
    $offlineConversionService = $user->GetService('OfflineConversionFeedService', ADWORDS_VERSION);
    // Create an upload conversion. Once created, this entry will be visible
    // under Tools and Analysis->Conversion and will have Source = "Import".
    $uploadConversion = new UploadConversion();
    $uploadConversion->category = 'PAGE_VIEW';
    $uploadConversion->name = $conversionName;
    $uploadConversion->viewthroughLookbackWindow = 30;
    $uploadConversion->ctcLookbackWindow = 90;
    $uploadConversionOperation = new ConversionTrackerOperation();
    $uploadConversionOperation->operator = 'ADD';
    $uploadConversionOperation->operand = $uploadConversion;
    $uploadConversionOperations = array($uploadConversionOperation);
    $result = $conversionTrackerService->mutate($uploadConversionOperations);
    $uploadConversion = $result->value[0];
    printf("New upload conversion type with name = '%s' and ID = %d was " . "created.\n", $uploadConversion->name, $uploadConversion->id);
    // Associate offline conversions with the upload conversion we created.
    $feed = new OfflineConversionFeed();
    $feed->conversionName = $conversionName;
    $feed->conversionTime = $conversionTime;
    $feed->conversionValue = $conversionValue;
    $feed->googleClickId = $gClId;
    $offlineConversionOperation = new OfflineConversionFeedOperation();
    $offlineConversionOperation->operator = 'ADD';
    $offlineConversionOperation->operand = $feed;
    $offlineConversionOperations = array($offlineConversionOperation);
    $result = $offlineConversionService->mutate($offlineConversionOperations);
    $feed = $result->value[0];
    printf('Uploaded offline conversion value of %d for Google Click ID = ' . "'%s' to '%s'.", $feed->conversionValue, $feed->googleClickId, $feed->conversionName);
}
开发者ID:planetfitnessnational,项目名称:googleads-php-lib,代码行数:38,代码来源:UploadOfflineConversions.php


示例13: GetAllImagesAndVideosExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 */
function GetAllImagesAndVideosExample(AdWordsUser $user)
{
    // Get the service, which loads the required classes.
    $mediaService = $user->GetService('MediaService', ADWORDS_VERSION);
    // Create selector.
    $selector = new Selector();
    $selector->fields = array('MediaId', 'Width', 'Height', 'MimeType', 'Name');
    $selector->ordering = array(new OrderBy('MediaId', 'ASCENDING'));
    // Create predicates.
    $selector->predicates[] = new Predicate('Type', 'IN', array('IMAGE', 'VIDEO'));
    // Create paging controls.
    $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
    do {
        // Make the get request.
        $page = $mediaService->get($selector);
        // Display images.
        if (isset($page->entries)) {
            foreach ($page->entries as $media) {
                if ($media->MediaType == 'Image') {
                    $dimensions = MapUtils::GetMap($media->dimensions);
                    printf("Image with dimensions '%dx%d', MIME type '%s', and id '%s' " . "was found.\n", $dimensions['FULL']->width, $dimensions['FULL']->height, $media->mimeType, $media->mediaId);
                } else {
                    if ($media->MediaType == 'Video') {
                        printf("Video with name '%s' and id '%s' was found.\n", $media->name, $media->mediaId);
                    }
                }
            }
        } else {
            print "No images or videos were found.\n";
        }
        // Advance the paging index.
        $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
    } while ($page->totalNumEntries > $selector->paging->startIndex);
}
开发者ID:googleads,项目名称:googleads-php-lib,代码行数:38,代码来源:GetAllImagesAndVideos.php


示例14: AddLocationExtensionOverrideExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $adId the id the ad to add the override to
 * @param string $campaignAdExtensionId the id of an existings campaign ad
 *     extension to override with
 */
function AddLocationExtensionOverrideExample(AdWordsUser $user, $adId, $campaignAdExtensionId)
{
    // Get the service, which loads the required classes.
    $adExtensionOverrideService = $user->GetService('AdExtensionOverrideService', ADWORDS_VERSION);
    // Create ad extenstion override.
    $adExtensionOverride = new AdExtensionOverride();
    $adExtensionOverride->adId = $adId;
    // Create ad extension using existing id.
    $adExtension = new AdExtension();
    $adExtension->id = $campaignAdExtensionId;
    $adExtensionOverride->adExtension = $adExtension;
    // Set override info (optional).
    $locationOverrideInfo = new LocationOverrideInfo();
    $locationOverrideInfo->radius = 5;
    $locationOverrideInfo->radiusUnits = 'MILES';
    $overrideInfo = new OverrideInfo();
    $overrideInfo->LocationOverrideInfo = $locationOverrideInfo;
    $adExtensionOverride->overrideInfo = $overrideInfo;
    // Create operations.
    $operation = new AdExtensionOverrideOperation();
    $operation->operand = $adExtensionOverride;
    $operation->operator = 'ADD';
    $operations = array($operation);
    // Make the mutate request.
    $result = $adExtensionOverrideService->mutate($operations);
    // Display results.
    if (isset($result->value)) {
        foreach ($result->value as $adExtensionOverride) {
            print 'Ad extension override with ad id "' . $adExtensionOverride->adId . '", ad extension id "' . $adExtensionOverride->adExtension->id . '", and type "' . $adExtensionOverride->adExtension->AdExtensionType . "\" was added.\n";
        }
    } else {
        print "No ad extension overrides were added.\n";
    }
}
开发者ID:sambavade,项目名称:google-api-adwords-php,代码行数:41,代码来源:AddLocationExtensionOverride.php


示例15: GetCampaignsExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 */
function GetCampaignsExample(AdWordsUser $user)
{
    // Get the service, which loads the required classes.
    $campaignService = $user->GetService('CampaignService', ADWORDS_VERSION);
    // Create selector.
    $selector = new Selector();
    $selector->fields = array('Id', '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 = $campaignService->get($selector);
        // Display results.
        if (isset($page->entries)) {
            foreach ($page->entries as $campaign) {
                printf("Campaign with name '%s' and ID '%s' was found.\n", $campaign->name, $campaign->id);
            }
        } else {
            print "No campaigns were found.\n";
        }
        // Advance the paging index.
        $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
    } while ($page->totalNumEntries > $selector->paging->startIndex);
}
开发者ID:stevenmaguire,项目名称:googleads-php-lib,代码行数:29,代码来源:GetCampaigns.php


示例16: GetAdGroupBidModifiersExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 */
function GetAdGroupBidModifiersExample(AdWordsUser $user)
{
    // Get the service, which loads the required classes.
    $bidModifierService = $user->GetService('AdGroupBidModifierService', ADWORDS_VERSION);
    // Create selector.
    $selector = new Selector();
    $selector->fields = array('CampaignId', 'AdGroupId', 'BidModifier', 'Id');
    $selector->ordering[] = new OrderBy('CampaignId', 'ASCENDING');
    // Create paging controls.
    $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
    do {
        // Make the get request.
        $page = $bidModifierService->get($selector);
        // Display results.
        if (isset($page->entries)) {
            foreach ($page->entries as $modifier) {
                $value = 'none';
                if (is_numeric($modifier->bidModifier)) {
                    $value = $modifier->bidModifier;
                }
                printf("Campaign ID %d, AdGroup ID %d, Criterion ID %d has ad group " . "level modifier: %s\n", $modifier->campaignId, $modifier->adGroupId, $modifier->criterion->id, $value);
            }
        } else {
            print "No bid modifiers were found.\n";
        }
        // Advance the paging index.
        $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
    } while ($page->totalNumEntries > $selector->paging->startIndex);
}
开发者ID:rochmit10,项目名称:googleads-php-lib,代码行数:33,代码来源:GetAdGroupBidModifiers.php


示例17: GetPlacementsExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $adGroupId the id of the parent ad group
 */
function GetPlacementsExample(AdWordsUser $user, $adGroupId)
{
    // Get the service, which loads the required classes.
    $adGroupCriterionService = $user->GetService('AdGroupCriterionService', ADWORDS_VERSION);
    // Create selector.
    $selector = new Selector();
    $selector->fields = array('PlacementUrl', 'Id');
    $selector->ordering[] = new OrderBy('PlacementUrl', 'ASCENDING');
    // Create predicates.
    $selector->predicates[] = new Predicate('AdGroupId', 'IN', array($adGroupId));
    $selector->predicates[] = new Predicate('CriteriaType', 'IN', array('PLACEMENT'));
    // Create paging controls.
    $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
    do {
        // Make the get request.
        $page = $adGroupCriterionService->get($selector);
        // Display results.
        if (isset($page->entries)) {
            foreach ($page->entries as $adGroupCriterion) {
                printf("Placement with URL '%s' and ID '%s' was found.\n", $adGroupCriterion->criterion->url, $adGroupCriterion->criterion->id);
            }
        } else {
            print "No placements were found.\n";
        }
        // Advance the paging index.
        $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
    } while ($page->totalNumEntries > $selector->paging->startIndex);
}
开发者ID:stevenmaguire,项目名称:googleads-php-lib,代码行数:33,代码来源:GetPlacements.php


示例18: GetProductServicesExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 */
function GetProductServicesExample(AdWordsUser $user, $productServiceSuggestion, $localeText)
{
    // Get the service, which loads the required classes.
    $productServiceService = $user->GetService('ProductServiceService', ADWORDS_VERSION);
    // Create selector.
    $selector = new Selector();
    $selector->fields = array('ProductServiceText');
    // Create predicates.
    $selector->predicates[] = new Predicate('ProductServiceText', 'EQUALS', array($productServiceSuggestion));
    $selector->predicates[] = new Predicate('Locale', 'EQUALS', array($localeText));
    // Create paging controls.
    $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
    do {
        // Make the get request.
        $page = $productServiceService->get($selector);
        // Display results.
        if (isset($page->entries)) {
            foreach ($page->entries as $productService) {
                printf("Product/service with text '%s' found\n", $productService->text);
            }
        } else {
            print "No products/services were found.\n";
        }
        // Advance the paging index.
        $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
    } while ($page->totalNumEntries > $selector->paging->startIndex);
}
开发者ID:googleads,项目名称:googleads-php-lib,代码行数:31,代码来源:GetProductServices.php


示例19: AddCampaignTargetingCriteriaExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $campaignId the id of the campaign to add targeting criteria to
 */
function AddCampaignTargetingCriteriaExample(AdWordsUser $user, $campaignId)
{
    // Get the service, which loads the required classes.
    $campaignCriterionService = $user->GetService('CampaignCriterionService', ADWORDS_VERSION);
    $campaignCriteria = array();
    // Create locations. The IDs can be found in the documentation or retrieved
    // with the LocationCriterionService.
    $california = new Location();
    $california->id = 21137;
    $campaignCriteria[] = new CampaignCriterion($campaignId, null, $california);
    $mexico = new Location();
    $mexico->id = 2484;
    $campaignCriteria[] = new CampaignCriterion($campaignId, null, $mexico);
    // Create languages. The IDs can be found in the documentation or retrieved
    // with the ConstantDataService.
    $english = new Language();
    $english->id = 1000;
    $campaignCriteria[] = new CampaignCriterion($campaignId, null, $english);
    $spanish = new Language();
    $spanish->id = 1003;
    $campaignCriteria[] = new CampaignCriterion($campaignId, null, $spanish);
    // Create operations.
    $operations = array();
    foreach ($campaignCriteria as $campaignCriterion) {
        $operations[] = new CampaignCriterionOperation($campaignCriterion, 'ADD');
    }
    // Make the mutate request.
    $result = $campaignCriterionService->mutate($operations);
    // Display results.
    foreach ($result->value as $campaignCriterion) {
        printf("Campaign targeting criterion with ID '%s' and type '%s' was " . "added.\n", $campaignCriterion->criterion->id, $campaignCriterion->criterion->CriterionType);
    }
}
开发者ID:phobik,项目名称:google-api-adwords-php,代码行数:38,代码来源:AddCampaignTargetingCriteria.php


示例20: GetAllDisapprovedAdsWithAwqlExample

/**
 * Runs the example.
 * @param AdWordsUser $user the user to run the example with
 * @param string $adGroupId the parent ad group id of the ads to retrieve
 */
function GetAllDisapprovedAdsWithAwqlExample(AdWordsUser $user, $adGroupId)
{
    // Get the service, which loads the required classes.
    $adGroupAdService = $user->GetService('AdGroupAdService', ADWORDS_VERSION);
    // Create a query.
    $query = sprintf('SELECT Id, AdGroupAdDisapprovalReasons WHERE AdGroupId = ' . '%d AND AdGroupCreativeApprovalStatus = DISAPPROVED ORDER BY Id', $adGroupId);
    // Create paging controls.
    $offset = 0;
    do {
        $pageQuery = sprintf('%s LIMIT %d,%d', $query, $offset, AdWordsConstants::RECOMMENDED_PAGE_SIZE);
        // Make the query request.
        $page = $adGroupAdService->query($pageQuery);
        // Display results.
        if (isset($page->entries)) {
            foreach ($page->entries as $adGroupAd) {
                printf("Ad with ID '%.0f', and type '%s' was disapproved for the " . "following reasons:\n", $adGroupAd->ad->id, $adGroupAd->ad->AdType);
                if (!empty($adGroupAd->disapprovalReasons)) {
                    foreach ($adGroupAd->disapprovalReasons as $reason) {
                        printf("\t'%s'\n", $reason);
                    }
                }
            }
        } else {
            print "No disapproved ads were found.\n";
        }
        // Advance the paging offset.
        $offset += AdWordsConstants::RECOMMENDED_PAGE_SIZE;
    } while ($page->totalNumEntries > $offset);
}
开发者ID:planetfitnessnational,项目名称:googleads-php-lib,代码行数:34,代码来源:GetAllDisapprovedAdsWithAwql.php



注:本文中的AdWordsUser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Addons类代码示例发布时间:2022-05-23
下一篇:
PHP AdWordsSoapClient类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap