如何在AppLozic中获取我的用户列表

时间:2016-11-17 21:24:44

标签: android firebase applozic

是否可以在不通过联系人添加的情况下获取所有用户。我的问题是我将用户存储在Firebase中,他们可以拥有隐藏的个人资料。我只需要获得具有可见配置文件的用户。我怎样才能做到这一点?

由于

1 个答案:

答案 0 :(得分:0)

您可以使用以下方法代码获取所有用户。您需要传递set类型的用户,然后您将在 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;
}