In this section, you will learn how to get a particular user detail using User class.
Getting user detail using User class
In this section, you will learn how to get a particular user detail using User class.
In the below example, you will learn how to extract twitter user's detail like his profile picture url, description, friends count, followers count, location etc through his profile name.
CODE
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="java.sql.*,twitter4j.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <% Twitter twitter = new TwitterFactory().getInstance(); //Getting user id through his screen name User user = twitter.showUser("Ankit_kaushal"); out.println("<h2>Displaying Twitter User's Detail of User -"+ user.getScreenName() + ">></h2><br/>"); out.println("User Image is below:<br/>"); out.println("<img src="+user.getProfileImageURL()+"/><br/>"); out.println("<b>User Status</b>"+user.getStatus()+"<br/>"); out.println("<b>User Description</b>"+user.getDescription()+"<br/>"); out.println("<b>User Followers Count</b>"+user.getFollowersCount()+"<br/>"); out.println("<b>User Friends Count</b>"+user.getFriendsCount()+"<br/>"); out.println("<b>User Location(profile)</b>"+user.getLocation()+"<br/>"); %> </body> </html>
OUTPUT
[ 0 ] Comments