Hi
I recently took over this process to upload user lists to Google audience.
I need to migrate it from AdWords API (Java client library) to the Google 
Ads API (Java client library).
I am not able to find the equivalent Ads API of the AdWords API used.

Still trying to understand the process and about Google Ads Audience but I 
think these methods are the main part of the process.

    private void getUserList(){
        log.info("get user list [{}]", audienceId);
        int offset = 0;
        //MR54558 reset userList for each List ID
        userList = null;
        SelectorBuilder builder = new SelectorBuilder();
        Selector selector = builder
                    .fields(AdwordsUserListField.Id, 
AdwordsUserListField.Size, AdwordsUserListField.Status)
                    .orderAscBy(AdwordsUserListField.Id)
                    .offset(offset)
                    .limit(PAGE_SIZE)
                    .build();
        try {
            UserListPage page;
            do{
                page = userListService.get(selector);
                UserList[] userLists = page.getEntries();
                if(userLists != null && userLists.length > 0){
                    for(UserList ul : userLists){
                        
if(audienceId.equalsIgnoreCase(ul.getId().toString())){
                            userList = ul;
                            break;
                        }
                    }
                }
                offset += PAGE_SIZE;
                selector = builder.increaseOffsetBy(PAGE_SIZE).build();
            }while (offset < page.getTotalNumEntries() && userList == null);
        } catch (RemoteException e) {
            log.error("fail to get user list [{}]", audienceId, e);
        }
    }

    private void mutateMembers(List<String> data, Operator operator) throws 
RemoteException {
        MutateMembersOperation operation = new MutateMembersOperation();
        MutateMembersOperand operand = new MutateMembersOperand();
        operand.setUserListId(userList.getId());

        List<Member> members = new ArrayList<>(data.size());
        for(String email : data){
            Member member = new Member();
            member.setHashedEmail(getHashedEmail(email));
            members.add(member);
        }
        operand.setMembersList(members.toArray(new Member[members.size()]));
        operation.setOperand(operand);
        operation.setOperator(operator);

        MutateMembersReturnValue result = userListService.mutateMembers(
                new MutateMembersOperation[]{operation}
        );

        UserList[] userListResult = result.getUserLists();
        String message = String.format("[%s], [%s] members %s in audience 
[%s][%s], upload status [%s], [%s] records found from csv",
                new SimpleDateFormat("yyyyMMdd").format(now().toDate()),
                members.size(), operator.getValue(), userList.getId(), 
userList.getName(),
                ((CrmBasedUserList) 
userListResult[0]).getDataUploadResult().getUploadStatus().getValue(), 
data.size());
        log.info("upload result : {}", message);
        if (Operator.ADD == operator) {
            addNotifyMessage(message);
        }
    }

May I know what are the Google Ads API I should use to achieve the same 
objectives?

Please let me know if the full listing of the codes is needed.

Thank you,
Derek

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 
"Google Ads API and AdWords 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/73e27856-5fc7-473c-8e7a-23d159da2d48n%40googlegroups.com.
  • Mi... derek
    • ... derek
      • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum
        • ... derek
          • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum

Reply via email to