I had implemented spring controller for fetching all the information about my friend list. The implementation are as follows:
@RequestMapping(value = "/getFbContactList/{accessToken}", method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
public String fbContactList(@PathVariable String accessToken) {
//accessToken recieved from facebook after OAuth authorization
Facebook facebook = new FacebookTemplate(accessToken);
System.out.println("User's FaceBook Profile Id::"+facebook.userOperations().getUserProfile().getId());
System.out.println("User's FaceBook UserName::"+facebook.userOperations().getUserProfile().getName());
System.out.println("User's FaceBook UserEmail::"+facebook.userOperations().getUserProfile().getEmail());
List<User> friends = facebook.friendOperations().getFriendProfiles();
for(User user : friends) {
System.out.println("User Email::" + user.getEmail());
}
return friends.toString();
}
The problem is that i am able to fetch my own information like Profile Id, User Name, Email,DOB but when i am printing the information about my friend's list it is not showing anything. It is having NULL values.
Can anyone give me some pointers where i am missing something.
A lot of this will depend on your friends' privacy settings and whether or not those friends have also used/authorized your app.
Your friends will not even be in the results from getFriendProfiles() if they have not themselves authorized your app to access their profiles. Before Facebook Graph API v2.0, you could fetch all of a user's friends, but that changed and now you only get friends who are also using the same app.
Once you get those friends, there are some fields that the app simply won't have access to no matter what privacy settings are in place. I don't recall off hand, but I believe email may be one of those. Further, if one of your friends has locked down their privacy settings, you won't be able to see many other fields as well. For cases where your app doesn't have authority to see a field, it will return null.
On the other hand...if you were to use a valid access token and request https://graph.facebook.com/me/friends?access_token={{YOUR TOKEN}} in your browser or using curl or some other client and you actually see your friends' data, then that very well could be a bug in Spring Social Facebook. But if you don't see that data, then there's no way that SSFB can get that data for you.