In this recipe, you'll learn how to retrieve a user's Twitter profile data, which automatically becomes available to the Twitter application once the user has authorized the Twitter application.
Here are the steps to retrieve data from the profile of a Twitter user:
In the
TwitterController
class, add aModel
argument to thetw()
method:@RequestMapping("/fw") public String fb(HttpServletRequest request, Model model) { ...
In that method, use the Twitter object to retrieve the user profile:
TwitterProfile profile = twitter.userOperations().getUserProfile();
Pass the user profile to the JSP view:
model.addAttribute("profile", profile);
In the JSP, display data from the user profile:
name: ${profile.name}<br /> screenName: ${profile.screenName}<br /> url: ${profile.url}<br /> profileImageUrl: ${profile.profileImageUrl}<br /> description: ${profile.description...