I am new and Please be patient If I am wrong. This below code is from RESTFB to fetch informations from profile. How should I extract name, id and pricture seperately.

Connection<User> myFriends = facebookClient.fetchConnection("me/friends",        User.class,Parameter.with("Fields", "name,id,picture"));
    Connection<Post> myFeed = facebookClient.fetchConnection("me/feed", Post.class);

    out.println("Count of my friends: " + myFriends.getData().size());
有帮助吗?

解决方案

the Name, ID and picture will be in a User class.

If you look at the USER.JAVA documentation in RestFB, you will see that you will be able to retrive various information that the user has.

Connection in RESTFB is a Collection, and it supports paging. It will only hold a maximum of 25 objects per request to Facebook. So if there are 50 users, each time you iterate through the Connection, you will only get 25 users. Hence you will have to iterate through the Connection until you get all 50 users.

If you actually read the examples in RestFB page, they show you how to iterate through the Connection to get data on each object it returns.

for (List<Post> myFeedConnectionPage : myFeed)
  for (Post post : myFeedConnectionPage)
    out.println("Post: " + post);

So you can do the same for the Connection, and store each User object in an array.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top