I am trying to do something extremely simple: change keyword bids. I think my code is correct but I'm probably wrong. I've searched the documentation for over four hours and can't find anything to help me. Unfortunately all other languages have examples of changing bids, the
PHP example focuses on changing keyword final URLs. All of the other examples in the forum are using outdated versions of the PHP library. Anyway, the code:
$adGroupCriterion = new BiddableAdGroupCriterion();
$adGroupCriterion->setAdGroupId($adGroupId);
$adGroupCriterion->setCriterion(new Criterion([KEYWORD_ID]));
$biddingStrategyConfiguration = new BiddingStrategyConfiguration();
$money = new Money;
$money->setMicroAmount(500000);
$bid = new CpcBid;
$bid->setBid($money);
$biddingStrategyConfiguration->setBids(new Bid([$bid]));
$operation = new AdGroupCriterionOperation();
$operation->setOperand($adGroupCriterion);
$operation->setOperator(Operator::SET);
$operations[] = $operation;
$result = $adGroupCriterionService->mutate($operations);
$adGroupCriterion = $result->getValue()[0];
Now the problem is that
$biddingStrategyConfiguration->setBids(new Bid([$bid])); always returns an error because it requires an array but
$bid->setBid($money); returns an object thus causing error. Am I doing something wrong here? Please help
.