Home Get friend list facebook 3.0
Reply: 0

Get friend list facebook 3.0

user11779 Published in September 19, 2018, 11:03 am

I'm trying to obtain my friend list from facebook using new SDK(3.0). I'm facing problems related to what kind of params I need to insert in a Bundle and how to use newMyFriendRequest and GraphAPI.

I didn't find on facebook documentation a place about what kind of field does we have to use. Based on GraphExplorer I insert in my Bundle the key "fields" with this string "id,name,friend" as a value. The code below shows what I'm doing right now. After I get My picture and name I execute newMyFriendRequest. I believe it uses GraphAPI by default.

I've seen here on StackOverflow some posts related:

How to send a FQL query with the new Android SDK

Facebook Android SDK request parameters: where find documentation?

It helps me little and I don't want to use FQL. For response II'm receiving this JSON like an answer:

{Response:  responseCode: 500, graphObject: null, error: {HttpStatus: 500, errorCode: 100, errorType: FacebookApiException, errorMessage: Unsupported operation}, isFromCache:false}

Notice I'm very new in Facebook SDK for Android.

private void onSessionStateChange(final Session session, SessionState sessionState, Exception ex){
    if(session != null && session.isOpened()){

private void getUserData(final Session session){
    Request request = Request.newMeRequest(session, 
        new Request.GraphUserCallback() {
        public void onCompleted(GraphUser user, Response response) {
            if(user != null && session == Session.getActiveSession()){

            if(response.getError() !=null){


private void getFriends(){
    Session activeSession = Session.getActiveSession();
        Request friendRequest = Request.newMyFriendsRequest(activeSession, 
            new GraphUserListCallback(){
                public void onCompleted(List<GraphUser> users,
                        Response response) {
                    Log.i("INFO", response.toString());

        Bundle params = new Bundle();
        params.putString("fields", "id,name,friends");
share|improve this question
  • 2
    Have you tried not setting any params? The id and name are there by default, so you don't have to request them. I don't think "friends" is a valid field. Try removing the Bundle and the setParameters altogether, and just call friendRequest.executeAsync(). – Ming Li Dec 19 '12 at 16:56
  • @MingLi Works fine with your observations. My intention is to get friendlist and profile image for each of them. For this, I believe I need to pass a parameter into a bundle. If this is true what param do I need to pass? See, facebook like I said is poor with this type of documentation. – learner Dec 19 '12 at 17:45
  • 2
    then what you want is "id,name,picture" for the "fields" parameter. You can also go to developers.facebook.com/tools/explorer to try out queries very quickly (in this case I used /me/friends?fields=id,name,picture). – Ming Li Dec 19 '12 at 19:27
  • @MingLi Ok, works very good. – learner Dec 20 '12 at 13:39
  • Sounds you had solved your problem, may I ask how you modify your code to get it work ? – RRTW May 9 '13 at 2:55

7 Answers 7

active oldest votes
up vote 22 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.417999 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO