In this recipe, you'll learn how to retrieve a Facebook user's profile data, which automatically becomes available to the app once the user has authorized it.
Here are the steps to retrieve the profile of a Facebook user:
In the
FacebookController
class, add a Model argument to thefb()
method:@RequestMapping("/fb") public String fb(HttpServletRequest request, Model model) { ...
In the
if(facebook.isAuthorized())
block, use the Facebook object to retrieve the user's profile:FacebookProfile profile = facebook.userOperations().getUserProfile();
Pass the user profile to the JSP view:
model.addAttribute("profile", profile);
In the JSP, display data from the user's profile:
id: ${profile.id}<br /> username: ${profile.username}<br /> name: ${profile.name}<br /> gender: ${profile.gender}<br /> email: ${profile.email}<br /> birthday: ${profile.birthday...