-2

I want to retrieve all Facebook friends list in my app. I have used "/me/taggable_friends/" api to get list of friends. I need ID of particular friend so that I can store it in database that this friend has been invited. BUT everytime it's giving different ID. Below is my graphrequest:

Bundle parameterstag = new Bundle();
            parameterstag.putString("limit", "5000");
            parameterstag.putString("fields", "id,name,gender");
            GraphRequest graphRequest = GraphRequest.newGraphPathRequest(AccessToken.getCurrentAccessToken(),"/me/taggable_friends/", new GraphRequest.Callback()
                    {
                        @Override
                        public void onCompleted(GraphResponse graphResponse) 
                        {
                            JSONObject jsonObject = graphResponse.getJSONObject();
                            try
                            {
                                if(jsonObject != null)
                                {
                                    String strJson = jsonObject.getString("data");
                                    Log.v("", "TAGG=="+strJson);
                                    JSONArray jArray=new JSONArray(strJson);
                                    for (int i = 0; i < jArray.length(); i++) 
                                    {
                                        String idfb = jArray.getJSONObject(i).getString("id");
                                        String namefb = jArray.getJSONObject(i).getString("name");

                                    }
                                }
                            }
                            catch (JSONException e)
                            {
                                e.printStackTrace();
                            }
                        }
                    });
            graphRequest.setAccessToken(AccessToken.getCurrentAccessToken());
            graphRequest.setParameters(parameterstag);
            graphRequest.executeAsync();

Or is there any other way to get frndslist who doesn't use your app also.

2
  • 1
    Facebook has deliberately restricted any app’s access to the user’s friends to those that are users of your app as well – so don’t try to find any “cheats” to work around this. Your app is not supposed to have access to friends that are not app users, and that’s it.
    – CBroe
    Oct 23, 2015 at 10:38
  • ok thanks but I just need to invite those friends who can use my app . I think this is not any "cheat" I'm doing just asking if anybody can help me out. thanks! Oct 26, 2015 at 6:39

2 Answers 2

1

You can't use the /me/taggable_friends call to replace the /me/friends. It's only there to tag friends in posts. /me/invitable_friends can only be used to invite friends to install a canvas app.

See

New features available in v2.0

  • Taggable Friends API: We've added a new endpoint called /me/taggable_friends that you can use in order to generate stories that have friends tagged in them, even those friends don't use your app. If you want to use the taggable friends API, your app will require review.
  • Invitable Friends API: We've added a new endpoint called /me/invitable_friends that you can use to generate a list of friends for someone to invite to your game through a custom interface. This API is only available to apps that are games on Facebook Canvas.

Also, see the question

3
  • Thanks for your reply! But my app requires user'd friend where they an send private message to their frnds about their offer.so does Facebook totally cancelled all these functionality? My app is not canvas so what should I do now? Oct 26, 2015 at 6:40
  • It's all in the docs I linked. There are no other possibilities.
    – Tobi
    Oct 26, 2015 at 8:11
  • Okay ! Thanks for your help Oct 26, 2015 at 9:24
0

Try this :

 new GraphRequest(
        AccessToken.getCurrentAccessToken(),
        "/me/taggable_friends",
        null,
        HttpMethod.GET,
        new GraphRequest.Callback() {
            public void onCompleted(GraphResponse response) {
                /* handle the result */
     JSONObject jsonObject = graphResponse.getJSONObject();
                            try
                            {
                                if(jsonObject != null)
                                {
                                    String strJson = jsonObject.getString("data");
                                    Log.v("", "TAGG=="+strJson);
                                    JSONArray jArray=new JSONArray(strJson);
                                    for (int i = 0; i < jArray.length(); i++) 
                                    {
                                        String idfb = jArray.getJSONObject(i).getString("id");
                                        String namefb = jArray.getJSONObject(i).getString("name");

                                    }
                                }
                            }
                            catch (JSONException e)
                            {
                                e.printStackTrace();
                            }

            }
        }
    ).executeAsync();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.