Mario Mouris
Mario Mouris

Reputation: 317

Facebook friends that have installed my app

I'm trying to retrieve a list of ids for friends that've installed my apps. I'm currently using this query, but it's returning 0 friends... Why is that?

GraphRequest request = GraphRequest.newGraphPathRequest(
                        token,
                        "/"+ facebookUserId +"/friends", response -> {
                            User newUser = new User();

                            if (response.getError() != null) {
                                //TODO: Handle error gracefully
                                Log.e("TEST", response.getError().getErrorMessage());
                                return;
                            }

                            try {
                                JSONArray listOfFriendsJson = response.getJSONObject()
                                        .getJSONArray("data");
                                Log.i("TEST", "Found " + listOfFriendsJson.length() + " friends");

                                for (int i=0 ; i < listOfFriendsJson.length() ; i++) {
                                    JSONObject friendJson = listOfFriendsJson.getJSONObject(i);
                                    newUser.friends_list.put(friendJson.getString("id"), true);
                                    Log.i("TEST", friendJson.getString("id"));
                                }
                            } catch (JSONException e) {
                                Log.e(LOG_TAG, "Error parsing response of GraphRequest", e);
                                //TODO: Stop loading and show error
                            }

                        });

Upvotes: 0

Views: 92

Answers (1)

andyrandy
andyrandy

Reputation: 73984

https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#4-4-2018

...Apps requesting the following permissions are now subject to heightened scrutiny during Login Review:

  • ...
  • user_friends
  • ...

I assume that the user_friends permission did not show up in the login dialog for your friend. Try adding your friend as Tester in the App settings and go through the login process again. Make sure you get asked for the user_friends permission on both phones.

Upvotes: 2

Related Questions