Hello Jeff,
KeywordMaxCpc is ok now.
The following is the code about adding the website criterion into
adGroup.
String alternateUrl = "
https://sandbox.google.com";
AdWordsUser user=new AdWordsUser(loginEmail, loginPassword,
clientEmail,
"", devToken, "",
"v13",new URL(alternateUrl));
CampaignInterface campaignService =
(CampaignInterface) user.getService
(AdWordsUser.CAMPAIGN_SERVICE);
AdGroupInterface adgroupService =
(AdGroupInterface) user.getService
(AdWordsUser.AD_GROUP_SERVICE);
AdInterface adService =
(AdInterface) user.getService(AdWordsUser.AD_SERVICE);
CriterionInterface criterionService =
(CriterionInterface) user.getService
(AdWordsUser.CRITERION_SERVICE);
Campaign newCampaign = new Campaign();
newCampaign.setBudgetAmount(new Long(100000000));
newCampaign.setBudgetPeriod(BudgetPeriod.Daily);
GeoTarget g_target = new GeoTarget();
String[] countries = {"FR", "ES"};
CountryTargets country = new CountryTargets();
country.setCountries(countries);
g_target.setCountryTargets(country);
newCampaign.setGeoTargeting(g_target);
String[] languages = {"en", "fr", "es"};
newCampaign.setLanguageTargeting(languages);
newCampaign.setStatus(CampaignStatus.Paused);
newCampaign = campaignService.addCampaign(newCampaign);
int campaign_id = newCampaign.getId();
AdGroup myAdGroup = new AdGroup();
myAdGroup.setKeywordMaxCpc(new Long(1000000));
AdGroup newAdGroup = adgroupService.addAdGroup(campaign_id,
myAdGroup);
long adgroup_id = newAdGroup.getId();
TextAd myAd = new TextAd();
myAd.setHeadline("AdWords API Dev Guide");
myAd.setDescription1("Access your AdWords");
myAd.setDescription2("accounts programmatically");
myAd.setDisplayUrl("
blog.chanezon.com");
myAd.setDestinationUrl("
http://blog.chanezon.com/");
myAd.setAdGroupId(adgroup_id);
Ad[] ads = new Ad[1];
ads[0] = myAd;
ads = adService.addAds(ads);
Website website1 = new Website();
website1.setCriterionType(CriterionType.Website);
website1.setUrl("
example.com");
boolean noError = false;
Criterion[] newWebsite ;
String[] languageTarget = new String[] {"en"};
GeoTarget geoTarget = new GeoTarget();
geoTarget.setCountryTargets(new CountryTargets(new String[]
{"US"},new String[]{}));
ApiError[] errors = criterionService.checkCriteria(new Criterion[]
{website1}, languageTarget, geoTarget);
if (errors == null) {
noError = true;
}
if(noError) newWebsite = criterionService.addCriteria(new
Criterion[] {website1});
The null error appears at this sentence whether I checked criteria or
not.
if(noError) newWebsite = criterionService.addCriteria(new Criterion
[] {website1});
Adding keyword and Ad are ok.
I used the same infomation about account.
Thanks and best regards,
PPL
On Apr 2, 11:16 pm, AdWords API Advisor <
adwordsapiadvi...@google.com>