Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve the user profile image from twitter

I am using the Twitter4J API in Java to retrieve the profile image for a Twitter user whose logged in. The command is something like :

twitter.getProfileImage(twitter.getScreenName(), Imagesize);

What is the image size? How can I display the ProfileImage object in a label for example?

like image 211
AhmadAssaf Avatar asked Jan 05 '11 16:01

AhmadAssaf


1 Answers

ok, the answer is :

Assume that the Twitter object is twitter

1 - get the user from the twitter object

User user = twitter.showUser(twitter.getid());

2 - get the profile image URL

URL url = user.getProfileImageURL();

3 - create Image icon

ImageIcon img = new ImageIcon(url);

4 - set the JLabel icon to be the ImageIcon

Jlabel1.setIcon(img);
like image 100
AhmadAssaf Avatar answered Oct 07 '22 11:10

AhmadAssaf