Getting user id through his screen name

Getting user id through his screen name


Posted in : Java Posted on : October 29, 2011 at 4:41 PM Comments : [ 0 ]

In this section, you will learn about getting user id of user and followers count through his screen name.

Getting user id through his screen name

In this section, you will learn about getting user id of user and followers count through his screen name.

In some function of twitter4j , you need user id for example for sending message to a user you need his user id. In the below example, you will learn how to extract twitter user id through his profile name

Given below the code :

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("<h3>Displaying user id of user "+ user.getScreenName() + "</h3><br/>");
out.println(user.getId());
%>
</body>
</html>

OUTPUT

Download Source Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics