dangtranduc / facebook-java-api

Automatically exported from code.google.com/p/facebook-java-api
0 stars 0 forks source link

I want All detail of Fasebook user & his friend #223

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
i got all friends' uID but i don't have idea to get further detail

Original issue reported on code.google.com by it.m...@gmail.com on 8 Jul 2009 at 5:36

GoogleCodeExporter commented 9 years ago
I'm able to get friend's UIDs list but not any further information(friend's) 
using 
following code.     

            FacebookXmlRestClient client = new FacebookXmlRestClient(apiKey, 
secretKey, sessionId);

        //set the client to run in batch mode
            client.beginBatch();

            //these commands will be batched
            client.users_getLoggedInUser();
            client.friends_get();

            //execute the batch (which also terminates batch mode until beginBatch is 
called again)
            List<? extends Object> batchResponse = client.executeBatch(false);

            //the list contains the results of the queries, in the same order they 
were defined
            Long userId = (Long) batchResponse.get(0);
            Document friends = (Document)batchResponse.get(1);
            NodeList nodes = friends.getElementsByTagName("uid");

            //print the results
            System.out.println("USER:  " + userId);
            for (int index = 0; index < nodes.getLength(); index++) {
                System.out.println("FRIEND:  " + 
nodes.item(index).getFirstChild().getTextContent());
            }

But I went through some link and tried with the following code snippet. I'm 
getting 
null as 'batchResponse'.

            FacebookJaxbRestClient Jclient = new FacebookJaxbRestClient(apiKey, 
secretKey, sessionId);

            Jclient.beginBatch();

            Jclient.users_getLoggedInUser();

            Jclient.friends_get(); 

            List<? extends Object> batchResponse = Jclient.executeBatch(false); 

            Long userId = (Long) batchResponse.get(0);
            FriendsGetResponse friends = (FriendsGetResponse)batchResponse.get(1);

btw, I'm using extended session key. Can you please let me know the workaround 
for 
this. Thanks

Original comment by imve...@gmail.com on 13 Jul 2009 at 1:27

GoogleCodeExporter commented 9 years ago
Not a defect.. To get friend's informations (JAXB) :

// Retreive friends UIds
FriendsGetResponse friends = client.friends_get();
// Specify the fields of the friends that interest you
List<ProfileField> fields = new Vector<ProfileField>();
fields.add(ProfileField.FIRST_NAME);
fields.add(ProfileField.LAST_NAME);
fields.add(ProfileField.PIC_SQUARE);
// Get all the requested fields on all the friends in one call
UsersGetInfoResponse friendsInfos = client.users_getInfo(friends.getUid(), 
fields);
// Iterate through friends
for (User user : friendsInfos.getUser()) {
... user.getFirstName() ...
}

Original comment by traxt...@gmail.com on 24 Jan 2010 at 10:18

GoogleCodeExporter commented 9 years ago
this and all the jwebscoket realy are a big waste of time..

Original comment by sandralj...@gmail.com on 9 May 2013 at 7:43