0
我想更新adwords中特定產品的最高每次點擊費用出價。 通過adui的webui這是一個微不足道的任務,但我不能讓它在代碼中工作,這是我迄今爲止。在廣告組中的某個特定購物產品上更新/設置maxcpc
import com.google.api.ads.adwords.axis.factory.AdWordsServices;
import com.google.api.ads.adwords.axis.v201607.cm.*;
import com.google.api.ads.adwords.lib.client.AdWordsSession;
import com.google.api.ads.common.lib.auth.OfflineCredentials;
import com.google.api.client.auth.oauth2.Credential;
import java.rmi.RemoteException;
public class ChangeBidOnSpecificProduct {
public static void main(String[] args) throws Exception {
OfflineCredentials build = new OfflineCredentials.Builder()
.forApi(OfflineCredentials.Api.ADWORDS)
.fromFile()
.build();
Credential oAuth2Credential = build
.generateCredential();
// Construct an AdWordsSession.
AdWordsSession session = new AdWordsSession.Builder()
.fromFile()
.withOAuth2Credential(oAuth2Credential)
.build();
String accountId = "ACCOUNT_ID";
Long campaignId = Long.valueOf("CAMPAIGN_ID");
long adGroupId = Long.valueOf("ADGROUP_ID");
session.setClientCustomerId(accountId);
Money money = new Money(null, 40000L);
String productId = "9200000050670959";
changeBidViaApi(session, campaignId, adGroupId, productId, money);
}
private static void changeBidViaApi(AdWordsSession session, Long campaignId, long adGroupId, String productId, Money newValue) throws RemoteException {
ProductOfferId productOfferId = new ProductOfferId();
productOfferId.setValue(productId);
ProductScope productScope = new ProductScope();
productScope.setDimensions(new ProductDimension[] {productOfferId});
BiddableAdGroupCriterion biddableAdGroupCriterion = new BiddableAdGroupCriterion();
biddableAdGroupCriterion.setAdGroupId(adGroupId);
biddableAdGroupCriterion.setCriterion(productScope);
BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
CpcBid bid = new CpcBid();
bid.setBid(newValue);
biddingStrategyConfiguration.setBids(new Bids[]{bid});
biddableAdGroupCriterion.setBiddingStrategyConfiguration(biddingStrategyConfiguration);
AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
operation.setOperand(biddableAdGroupCriterion);
operation.setOperator(Operator.SET);
AdGroupCriterionOperation[] operations = new AdGroupCriterionOperation[]{operation};
AdWordsServices adWordsServices = new AdWordsServices();
AdGroupCriterionServiceInterface adGroupCriterionService =
adWordsServices.get(session, AdGroupCriterionServiceInterface.class);
AdGroupCriterionReturnValue result = adGroupCriterionService.mutate(operations);
}
}
執行這將導致一個錯誤: '解組錯誤:CVC-elt.4.2:無法解析 'NS2:ProductScope' 的類型定義爲元素 'NS2:標準''。
這是(anonimized)數據被髮送到谷歌:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:RequestHeader soapenv:mustUnderstand="0" xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201607">
<ns1:clientCustomerId>ACCOUNT_ID</ns1:clientCustomerId>
<ns1:developerToken>MY_DEV_TOKEN</ns1:developerToken>
<ns1:userAgent>MY_UA</ns1:userAgent>
<ns1:validateOnly>false</ns1:validateOnly>
<ns1:partialFailure>false</ns1:partialFailure>
</ns1:RequestHeader>
</soapenv:Header>
<soapenv:Body>
<mutate xmlns="https://adwords.google.com/api/adwords/cm/v201607">
<operations>
<operator>SET</operator>
<operand xsi:type="ns2:BiddableAdGroupCriterion" xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201607">
<ns2:adGroupId>ADGROUP_ID</ns2:adGroupId>
<ns2:criterion xsi:type="ns2:ProductScope">
<ns2:dimensions xsi:type="ns2:ProductOfferId">
<ns2:value>9200000050670959</ns2:value>
</ns2:dimensions>
</ns2:criterion>
<ns2:biddingStrategyConfiguration>
<ns2:bids xsi:type="ns2:CpcBid">
<ns2:bid>
<ns2:microAmount>1</ns2:microAmount>
</ns2:bid>
</ns2:bids>
</ns2:biddingStrategyConfiguration>
</operand>
</operations>
</mutate>
</soapenv:Body>
</soapenv:Envelope>
任何建議,對錯誤的原因還是什麼,我做錯了什麼?