// Get AdWordsUser from "~/adwords.properties".
AdWordsUser user = new AdWordsUser();
// Get the CampaignService.
CampaignServiceInterface campaignService =
user.getService(AdWordsService.V201309.CAMPAIGN_SERVICE);
// Create campaign.
Campaign campaign = new Campaign();
campaign.setName("Interplanetary Cruise #" + System.currentTimeMillis());
campaign.setStatus(CampaignStatus.PAUSED);
// Create the bids.
BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
ManualCpcBiddingScheme manualCpc = new ManualCpcBiddingScheme();
manualCpc.setEnhancedCpcEnabled(false);
biddingConfig.setBiddingScheme(manualCpc);
campaign.setBiddingStrategyConfiguration(biddingConfig);
BudgetServiceInterface budgetService = user.getService(AdWordsService.V201309.BUDGET_SERVICE);
// Create budget.
Budget budget = new Budget();
budget.setName("Interplanetary Budget #" + System.currentTimeMillis());
budget.setPeriod(BudgetBudgetPeriod.DAILY);
budget.setAmount(new Money(null, 50000000L));
budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
// Add budget.
BudgetOperation budgetOperation = new BudgetOperation();
budgetOperation.setOperand(budget);
budgetOperation.setOperator(Operator.ADD);
BudgetReturnValue budgetReturnValue =
budgetService.mutate(new BudgetOperation[] {budgetOperation});
// Set the budget to the campaign.
Budget createdBudget = new Budget();
createdBudget.setBudgetId(budgetReturnValue.getValue(0).getBudgetId());
campaign.setBudget(createdBudget);
// Set the campaign network options to Search and Search Network.
NetworkSetting networkSetting = new NetworkSetting();
networkSetting.setTargetGoogleSearch(true);
networkSetting.setTargetSearchNetwork(true);
networkSetting.setTargetContentNetwork(false);
networkSetting.setTargetPartnerSearchNetwork(false);
campaign.setNetworkSetting(networkSetting);
// Set options that are not required.
GeoTargetTypeSetting geoTarget = new GeoTargetTypeSetting();
geoTarget.setPositiveGeoTargetType(GeoTargetTypeSettingPositiveGeoTargetType.DONT_CARE);
KeywordMatchSetting keywordMatch = new KeywordMatchSetting();
keywordMatch.setOptIn(Boolean.FALSE);
campaign.setSettings(new Setting[] {geoTarget, keywordMatch});
// Create operations.
CampaignOperation operation = new CampaignOperation();
operation.setOperand(campaign);
operation.setOperator(Operator.ADD);
CampaignOperation[] operations = new CampaignOperation[] {operation};
// Add campaign.
CampaignReturnValue result = campaignService.mutate(operations);
// Display campaigns.
if (result != null && result.getValue() != null) {
for (Campaign campaignResult : result.getValue()) {
System.out.println("Campaign with name \"" + campaignResult.getName() + "\" and id \""