How to get list of my users in AppLozic

时间秒杀一切 提交于 2019-12-11 02:08:13

问题


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;
}


来源:https://stackoverflow.com/questions/40665300/how-to-get-list-of-my-users-in-applozic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!