简体   繁体   中英

How to get a list of friend's Facebook ID's from Graph API on Android?

I found this question , which does exactly what I want it to do, but the Facebook class has been deprecated in favor of the Facebook Graph API. I'm having trouble understanding the documentation that Facebook gives, so if anyone could offer help, it would be much appreciated!

I would suggest checking out the Facebook Android SDK (supported by Facebook) that supports the Graph API.

It has an Android FriendPicker sample that should cover your needs.

public void getIds(){
    Session session = Session.getActiveSession();
    String fqlQuery = "select uid from user where uid in (select uid2 from friend where uid1 = me())";
    Bundle params = new Bundle();
    params.putString("q", fqlQuery);
    Request request = new Request(session, "/fql", params, HttpMethod.GET,
            new Callback() {

                @Override
                public void onCompleted(Response response) {

                    Log.d("List of id's", "response = "+response);
                }
            });
    Request.executeBatchAsync(request); 
}
public void getIds(){
            Session session = Session.getActiveSession();
            String query = "select uid from user where uid in (select uid2 from friend where uid1 = me())";
            Bundle params = new Bundle();
            params.putString("q", query);
            Request request = new Request(session, "/me/friends", params, HttpMethod.GET, new Request.Callback() {

                        @Override
                        public void onCompleted(Response response) {

                            Log.d("Id's :", "Response = "+response);
                        }
                    });
            Request.executeBatchAsync(request); 
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM