I am using AdwordsAPI 

Error:
[CampaignCriterionError.CANNOT_EXCLUDE_CRITERIA_TYPE @ 
operations[0].operand.criterion; trigger:'PLATFORM']


Code I am Trying with : 

$campaign_id = "";
$campaignService = $adWordsServices->get(sessionBuilder(), 
CampaignService::class);
$campaignCriterionService = $adWordsServices->get(sessionBuilder(), 
CampaignCriterionService::class);
// Create a campaign
$campaign = new Campaign();
$campaign->setName("New Campaign".' #' . uniqid()); //Set Campaign Name
$campaign->setAdvertisingChannelType(AdvertisingChannelType::DISPLAY);

//Budget Start
$budgetService = $adWordsServices->get(sessionBuilder(), BudgetService::class);
$budget = new Budget();
$budget->setName(' Budget #' . uniqid());
$budget->setIsExplicitlyShared(false);
$money = new Money();
$money->setMicroAmount((int)(500* 1000000));
$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];
//Budget End

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

// Bidding Strategy
$biddingStrategyConfiguration = new BiddingStrategyConfiguration();
$biddingStrategyConfiguration->setBiddingStrategyType(BiddingStrategyType::MANUAL_CPM);
$campaign->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

//Pause Campaign
$campaign->setStatus(CampaignStatus::PAUSED);

// Create a campaign operation and add it to the operations list.
$operations = [];
$operation = new CampaignOperation();
$operation->setOperand($campaign);
$operation->setOperator(Operator::ADD);
$operations[] = $operation;
// Create the campaigns on the server
$resultCampaign = $campaignService->mutate($operations)->getValue()[0];
$campaign_id = $resultCampaign->getId();

$platform = new \Google\AdsApi\AdWords\v201809\cm\Platform();
$platform->setId('30002');

$criterion = new NegativeCampaignCriterion();
$criterion->setCampaignId($campaign_id);
$criterion->setCriterion($platform);

// Create a campaign criterion operation and add it to the operations list.
$operation = new CampaignCriterionOperation();
$operation->setOperator(Operator::ADD);
$operation->setOperand($criterion);
$operations = [$operation];
// Update campaign criteria on the server.
$results = $campaignCriterionService->mutate($operations);

return $result;

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/0c0ee77f-0a49-4c75-8879-69f75e653fe3%40googlegroups.com.

Reply via email to