Update remarketing email list from php

79 views
Skip to first unread message

testapi...@gmail.com

unread,
Aug 26, 2016, 9:24:52 AM8/26/16
to AdWords API Forum
Hello :)

It's my code:
    public function AdAudience($name,$desc='',$emaillist='',$idgr  =''){
        $audience_id
= '';

   
try {
     require_once dirname
(dirname(__FILE__)) . '/Google/init.php';

     $user
= new AdWordsUser();

     $user
->LogAll();
      $EMAILS
= array();
     
foreach ($emaillist as $key => $value) {
        $EMAILS
[]=$value;
     
}


     $userListService
= $user->GetService('AdwordsUserListService',
      ADWORDS_VERSION
);


     $userList
= new CrmBasedUserList();
$userList
->id = $idgr;

     $operation
= new UserListOperation();
     $operation
->operand = $userList;
     $operation
->operator = 'SET';

     $operations
= array($operation);
     
     $result
= $userListService->mutate($operations);
     $userListAdded
= $result->value[0];
     
     $audience_id
=  $idgr;
     $userListId
= $idgr;
     
     
     $mutateMembersOperation
= new MutateMembersOperation();
     $operand
= new MutateMembersOperand();
     $operand
->userListId = $userListId;

 
// You can optionally provide this field.
     $operand
->dataType = 'EMAIL_SHA256';

     $emailHashes
= array();
     
foreach ($EMAILS as $email) {
      $emailHashes
[] = hash('sha256', strtolower(trim($email)));
   
}
    $operand
->members = $emailHashes;
    $mutateMembersOperation
->operand = $operand;
    $mutateMembersOperation
->operator = 'SET';

    $mutateMembersOperations
= array($mutateMembersOperation);

    $mutateMembersResult
=
    $userListService
->mutateMembers($mutateMembersOperations);






 
} catch (Exception $e) {
    printf
("An error has occurred: %s\n", $e->getMessage());
 
}


 
return array(
   
"id"=>$audience_id,
   
"name"=>$name
   
);

}



Audience has already been created, now they need to add recipients, or e-mail addresses. I wrote this function but unfortunately gets error:

[OperatorError.OPERATOR_NOT_SUPPORTED @ operations[0]]


testapi...@gmail.com

unread,
Aug 26, 2016, 9:28:32 AM8/26/16
to AdWords API Forum
Additionaly, when I add email before, during update I should add only new email or old and new ? I need have old and new email in remarketing list.

Vishal Vinayak (Adwords API Team)

unread,
Aug 26, 2016, 4:23:20 PM8/26/16
to AdWords API Forum
Hi,

mutateMembers only allows for ADD and REMOVE operations, i.e. you cannot user SET operation. Also, I would recommend adding only the new email addresses.

Regards,
Vishal, AdWords API Team

testapi...@gmail.com

unread,
Aug 27, 2016, 12:40:05 PM8/27/16
to AdWords API Forum
Thank you :)

My question maby is stupid but on the google documentation operations SET is exist.

https://developers.google.com/adwords/api/docs/reference/v201607/AdwordsUserListService.MutateMembersOperation#operator





And it made it so I did.
One more time thanks ;)

Vishal Vinayak (Adwords API Team)

unread,
Aug 29, 2016, 11:30:20 AM8/29/16
to AdWords API Forum
Hi,

Thanks for bringing this issue to our notice. I will work with my team and get the documentation corrected. 
Reply all
Reply to author
Forward
0 new messages