输入&#ns; ns1:预算'不能从元素定义'广告系列',元素' ns1:操作数'

时间:2017-03-10 14:52:00

标签: php google-api google-adwords

将此套餐用于laravel:https://github.com/nikolajlovenhardt/laravel-google-ads

当我尝试撰写广告系列时,会发生以下错误:

  

AdsSoapClient.php第115行中的SoapFault:解组错误:   cvc-elt.4.3:输入&#ns; ns1:预算'不是从类型中有效地派生的   元素' ns1:操作数'的定义'广告系列'。

soap.log:http://pastebin.com/raw/TmU6XSfp

  

[2017-03-10 14:33:57] AW_SOAP.INFO:clientCustomerId = 556-905-2150   operations = 1 service = BudgetService method = mutate responseTime = 145   requestId = 00054a61407809890a378107c00d151f server = adwords.google.com   isFault = 0 faultMessage = [2017-03-10 14:33:58] AW_SOAP.WARNING:   clientCustomerId = 556-905-2150 operations = service = CampaignService   method = mutate responseTime = requestId = server = adwords.google.com   isFault = 1 faultMessage = Unmarshalling Error:cvc-elt.4.3:Type   ' NS1:预算'无法从类型定义中有效地派生,   '广告系列',元素&#ns; ns1:操作数'。 [2017-03-10 14:33:58]   AW_SOAP.NOTICE:POST / api / adwords / cm / v201609 / CampaignService?wsdl   HTTP / 1.1主机:adwords.google.com连接:Keep-Alive User-Agent:   PHP-SOAP / 7.1.2-3 + deb.sury.org~xenial + 1 Content-Type:text / xml;   charset = utf-8 SOAPAction:""内容长度:1436授权:   数据被编辑

     

556-905-2150REDACTEDunknown   (AwApi-PHP,googleads-php-lib / 25.2.0,   PHP / 7.1.2-3 + deb.sury.org~xenial + 1)falsefalseADDInterplanetary Cruise Budget

     

58c2b955417e250000000STANDARDADDInterplanetary Cruise

     

58c2b955cc997PAUSED1050511653DISPLAYMANUAL_CPC

     

HTTP / 1.1 500内部服务器错误内容类型:text / xml;   charset = UTF-8日期:2017年3月10日星期五14:33:58 GMT到期日:星期五,3月10日   2017 14:33:58 GMT Cache-Control:private,max-age = 0   X-Content-Type-Options:nosniff X-Frame-Options:SAMEORIGIN   X-XSS-Protection:1; mode = block服务器:GSE Alt-Svc:quic =":443&#34 ;;   MA = 2592000; V =" 36,35,34" Accept-Ranges:none Vary:Accept-Encoding   Transfer-Encoding:chunked

     

皂:ClientUnmarshalling   错误:cvc-elt.4.3:输入&#ns; ns1:预算'不是来自   类型定义'广告系列'元素&#ns; ns1:操作数'。   

从"基本操作样本"

复制
$customerClientId = 'xxx-xxx-xxxx';

$adWordsService = new AdWordsService();

/** @var BudgetService $budgetService */
$budgetService = $adWordsService->getService(BudgetService::class, $customerClientId);

// Create the shared budget (required).
$budget = new Budget();
$budget->setName('Interplanetary Cruise Budget #' . uniqid());
$money = new Money();
$money->setMicroAmount(50000000);
$budget->setAmount($money);
$budget->setDeliveryMethod(BudgetBudgetDeliveryMethod::STANDARD);

$operations = [];

// Create a budget operation.
$operation = new BudgetOperation();
$operation->setOperand($budget);
$operation->setOperator(Operator::ADD);
$operations[] = $operation;

// Create the budget on the server.
$result = $budgetService->mutate($operations);
$budget = $result->getValue()[0];

// Create a campaign with only required settings.
$campaign = new Campaign();
$campaign->setName('Interplanetary Cruise #' . uniqid());
$campaign->setAdvertisingChannelType(AdvertisingChannelType::DISPLAY);

// Set shared budget (required).
$campaign->setBudget(new Budget());
$campaign->getBudget()->setBudgetId($budget->getBudgetId());

// Set bidding strategy (required).
$biddingStrategyConfiguration = new BiddingStrategyConfiguration();
$biddingStrategyConfiguration->setBiddingStrategyType(
        BiddingStrategyType::MANUAL_CPC);
$campaign->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

$campaign->setStatus(CampaignStatus::PAUSED);

// Create a campaign operation and add it to the operations list.
$operation = new CampaignOperation();
$operation->setOperand($campaign);
$operation->setOperator(Operator::ADD);
$operations[] = $operation;

/** @var CampaignService $campaignService */
$campaignService = $adWordsService->getService(CampaignService::class, $customerClientId);

$result = $campaignService->mutate($operations);

foreach ($result->getValue() as $campaign) {
    printf("Campaign with name '%s' and ID %d was added.\n",
        $campaign->getName(),
        $campaign->getId()
    );
}

使用示例代码接收广告系列有效...

1 个答案:

答案 0 :(得分:0)

我认为,这是因为,您制作了 $campaignService->mutate($operations);有预算操作

$operations = [];
// Create a budget operation.
$operation = new BudgetOperation();
$operation->setOperand($budget);
$operation->setOperator(Operator::ADD);
$operations[] = $operation;

// Create a campaign operation and add it to the operations list.
$operation = new CampaignOperation();
$operation->setOperand($campaign);
$operation->setOperator(Operator::ADD);
$operations[] = $operation;

$result = $campaignService->mutate($operations);

你需要做 $operations = [];再次之前 $campaignService->mutate($operations);

$operations = [];
// Create a campaign operation and add it to the operations list.
$operation = new CampaignOperation();
$operation->setOperand($campaign);
$operation->setOperator(Operator::ADD);
$operations[] = $operation;

/** @var CampaignService $campaignService */
$campaignService = $adWordsService->getService(CampaignService::class, $customerClientId);
$result = $campaignService->mutate($operations);