How to get list of my users in AppLozic

2019-07-21 03:25发布

问题:

is it possible to get all of my users without adding them to through contacts. My problem is that I store users in Firebase and they can have invisible profile. I need to get only users with visible profiles. How can I achieve this?

Thanks

回答1:

You can use the below method code for getting all the user users .You need to pass the users of set type then you will get the response in if(!TextUtils.isEmpty(response)){

public String postUserDetailsByUserIds(Set<String> userIds) {
    try {
        HttpRequestUtils httpRequestUtils =    new HttpRequestUtils(this);
       final  String userDetailsUrl = "https://apps.applozic.com/rest/ws/user/detail";
        if (userIds !=null && userIds.size()>0  ) {
            List<String> userDetailsList = new ArrayList<>();
            String response = "";
            int count = 0;
            for (String userId : userIds) {
                count++;
                userDetailsList.add(userId);
                if( count% 60==0){
                    UserDetailListFeed userDetailListFeed = new UserDetailListFeed();
                    userDetailListFeed.setContactSync(true);
                    userDetailListFeed.setUserIdList(userDetailsList);
                    String jsonFromObject = GsonUtils.getJsonFromObject(userDetailListFeed, userDetailListFeed.getClass());
                    Log.i(TAG,"Sending json:" + jsonFromObject);
                    response = httpRequestUtils.postData(userDetailsUrl + "?contactSync=true", "application/json", "application/json", jsonFromObject);
                    userDetailsList =  new ArrayList<String>();
                    if(!TextUtils.isEmpty(response)){
                            List<UserDetail> userDetails = (List<UserDetail>) GsonUtils.getObjectFromJson(response, new TypeToken<List<UserDetail>>() {}.getType());
                            for (UserDetail userDetail : userDetails) {
                                //Here you will get the user details
                                Log.i("UserDeatil","userId:"+userDetail.getUserId()) ;

                                Log.i("UserDeatil","display name:"+userDetail.getDisplayName()) ;

                                Log.i("UserDeatil","image link:"+userDetail.getImageLink()) ;

                                Log.i("UserDeatil","phone number:"+userDetail.getPhoneNumber()) ;
                            }
                    }
                }
            }
            if(!userDetailsList.isEmpty()&& userDetailsList.size()>0) {
                UserDetailListFeed userDetailListFeed = new UserDetailListFeed();
                userDetailListFeed.setContactSync(true);
                userDetailListFeed.setUserIdList(userDetailsList);
                String jsonFromObject = GsonUtils.getJsonFromObject(userDetailListFeed, userDetailListFeed.getClass());
                response = httpRequestUtils.postData(userDetailsUrl + "?contactSync=true", "application/json", "application/json", jsonFromObject);

                Log.i(TAG, "User details response is :" + response);
                if (TextUtils.isEmpty(response) || response.contains("<html>")) {
                    return null;
                }

                if (!TextUtils.isEmpty(response)) {
                    List<UserDetail> userDetails = (List<UserDetail>) GsonUtils.getObjectFromJson(response, new TypeToken<List<UserDetail>>() {}.getType());
                    for (UserDetail userDetail : userDetails) {

                        //Here you will get the user details 
                        Log.i("UserDeatil","userId:"+userDetail.getUserId()) ;

                        Log.i("UserDeatil","display name:"+userDetail.getDisplayName()) ;

                        Log.i("UserDeatil","image link:"+userDetail.getImageLink()) ;

                        Log.i("UserDeatil","phone number:"+userDetail.getPhoneNumber()) ;
                    }                    }
            }
            return response;
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}