AdGroupLabelOperation in PHP, How To?

26 views
Skip to first unread message

John VV

unread,
Nov 24, 2017, 3:58:12 PM11/24/17
to AdWords API Forum

I am using the PHP Library to add a label to an adGroup but having some problems with the operation:

$ad_group_id = '123456';
$labels
= array('78910');
operations
= array();
foreach($labels as $label_id){
      $adGroupLabel
= new AdGroupLabel();
      $adGroupLabel
->setAdGroupId($ad_group_id);
      $adGroupLabel
->setLabelId($label_id);
      $operation
= new AdGroupLabelOperation();
      $operation
->setOperand($adGroupLabel);
      $operation
->setOperator(Operator::ADD);
      $operations
[] = $operation;
}
$result
= $adGroupService->mutate($operations);



But I get the error
Unmarshalling Error: cvc-elt.4.3: Type 'ns1:AdGroupLabelOperation' is not validly derived from the type definition, 'AdGroupOperation', of element 'ns1:operations'. 


Sadly there are very few examples of this so hopefully I can find some insight in sharing my problem.

John VV

unread,
Nov 24, 2017, 4:35:48 PM11/24/17
to AdWords API Forum
I finally found the answer.
But bonus mutateLabels is not a valid function for adgroups so digging into the library code I found "mutateLabel" and voila.
$adGroupService->mutateLabel($operations);
Is what you'll need.
Reply all
Reply to author
Forward
0 new messages