简体   繁体   English

Android Facebook SDK 如何获取安装我的应用程序的所有好友列表

[英]Android Facebook SDK How to get all friends list who installed my app

i succeeded to get friends who installed my app BUT i have a case which is that some friends who already installed my app ,I could not find them when i request to get the list of friends who installed my app .我成功地找到了安装我的应用程序的朋友,我有一个案例,即一些已经安装了我的应用程序的朋友,当我请求获取安装我的应用程序的朋友列表时找不到他们。 i guess the are not listed due to their Facebook privacy .我猜由于他们的 Facebook 隐私没有列出。 is it right ?是吗? or what is the problem ?或者有什么问题?

Here is my request code这是我的请求代码

        public void find_facebook_friends()
{            

    GraphRequest request = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(), new GraphRequest.GraphJSONObjectCallback()
    {
        @Override
        public void onCompleted(JSONObject object, GraphResponse response)
        {

            JSONObject json = response.getJSONObject();

            try
            {
                String friend_name = null;
                String friend_id = null;
                if (json != null)
                {
                    String js = json.toString();
                    String res = response.toString();
                    JSONObject c = response.getJSONObject();
                    JSONObject myfriends = null;

                    try
                    {
                        myfriends = c.getJSONObject("friends");
                    }
                    catch (JSONException e)
                    {
                        e.printStackTrace();
                    }

                    if (myfriends != null)
                    {
                        JSONArray mydata = myfriends.getJSONArray("data");
                        facebookfriends_namesArray = null;
                        facebookfriends_idArray = null;
                        for (int i = 0; i < mydata.length(); i++)
                        {

                            JSONObject jsonobject = mydata.getJSONObject(i);
                            friend_id = jsonobject.getString("id");
                            friend_name = jsonobject.getString("name");
                        }
                    }

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

            }
        }
    });
    Bundle parameters = new Bundle();
    parameters.putString("fields", "id,name,link,email,picture,gender,friends, birthday,first_name,last_name,locale,timezone,updated_time,verified,friendlists");
  request.setParameters(parameters);
    request.executeAsync();
}

Try this.试试这个。 Please make sure your read permissions include user_friends as follows请确保您的阅读权限包括user_friends如下

loginButton.setReadPermissions("email", "public_profile","user_friends");
        loginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                Log.d(TAG, "facebook:onSuccess:" + loginResult);

            }

            @Override
            public void onCancel() {
                Log.d(TAG, "facebook:onCancel");
            }

            @Override
            public void onError(FacebookException error) {
                Log.d(TAG, "facebook:onError", error);
            }
        });

Then get friends like this然后交这样的朋友

 GraphRequest request = GraphRequest.newMyFriendsRequest(AccessToken.getCurrentAccessToken(), new GraphRequest.GraphJSONArrayCallback() {
                                    @Override
                                    public void onCompleted(JSONArray jsonArray, GraphResponse graphResponse) {

}
});

or by get request或通过获取请求

String urll="https://graph.facebook.com/v2.7/me/friends?access_token="+ user accesstoken;

Refer:- https://coderzpassion.com/android-using-facebook-login-application-using-latest-facebook-sdk/参考:- https://coderzpassion.com/android-using-facebook-login-application-using-latest-facebook-sdk/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Facebook SDK Android获得使用相同应用程序的朋友 - Facebook sdk android get friends who use the same app 我怎样才能让所有不使用我的应用程序或不通过我的应用程序登录的 Facebook 朋友 - How can i get all facebook friends who is not using my app or not login through my app 如何通过Facebook SDK Android获取当前正在使用我的应用程序的在线朋友 - How to get online friends who are currently using my application through Facebook sdk android 显示拥有适用于Android的Facebook Facebook SDK的朋友的朋友 - Show friends of friends who have the app facebook sdk for android 如何查找我的Android用户的Facebook朋友列表? - How to find list of my facebook friends who are android users? 如何在Android中使用Facebook SDK获取Facebook朋友列表 - How to get facebook friends list using facebook sdk in android 如何获取所有用户朋友的列表(不仅是使用该应用程序的用户)? - how to get a list of all user friends (not only who use the app)? 获取已安装应用程序的Facebook朋友列表 - Get list of Facebook friends that have the app installed 如何使用Android Facebook SDK获取完整的朋友列表 - How to get the full friends list using the Android Facebook SDK Android获得有app下载的Facebook好友 - Android get Facebook friends who have app downloaded
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM