*/
private static Campaign createCampaignWithBiddingStrategy(
AdWordsServices adWordsServices, AdWordsSession session, Long biddingStrategyId,
Long sharedBudgetId) throws ApiException, RemoteException, ServiceException {
// Get the CampaignService, which loads the required classes.
CampaignServiceInterface campaignService =
adWordsServices.get(session, CampaignServiceInterface.class);
// Create campaign.
Campaign campaign = new Campaign();
campaign.setName("Interplanetary Cruise #" + System.currentTimeMillis());
// Set the budget.
Budget budget = new Budget();
budget.setBudgetId(sharedBudgetId);
campaign.setBudget(budget);
// Set bidding strategy (required).
BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
biddingStrategyConfiguration.setBiddingStrategyId(biddingStrategyId);
campaign.setBiddingStrategyConfiguration(biddingStrategyConfiguration);
// Set keyword matching setting (required).
KeywordMatchSetting keywordMatchSetting = new KeywordMatchSetting();
keywordMatchSetting.setOptIn(true);
campaign.setSettings(new Setting[] {keywordMatchSetting});
// Set advertising channel type (required).
campaign.setAdvertisingChannelType(AdvertisingChannelType.SEARCH);
// Set network targeting (recommended).
NetworkSetting networkSetting = new NetworkSetting();
networkSetting.setTargetGoogleSearch(true);
networkSetting.setTargetSearchNetwork(true);
networkSetting.setTargetContentNetwork(true);
campaign.setNetworkSetting(networkSetting);
// Create operation.
CampaignOperation operation = new CampaignOperation();
operation.setOperand(campaign);
operation.setOperator(Operator.ADD);
CampaignReturnValue result = campaignService.mutate(new CampaignOperation[] {operation});
Campaign newCampaign = result.getValue(0);
System.out.printf("Campaign with name '%s', ID %d and bidding scheme ID %d was created.\n",
newCampaign.getName(), newCampaign.getId(),
newCampaign.getBiddingStrategyConfiguration().getBiddingStrategyId());