从 Twitter 检索用户个人资料图片 [英] Retrieve the user profile image from twitter

查看:89
本文介绍了从 Twitter 检索用户个人资料图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Java 中的 Twitter4J API 来检索已登录的 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);

图片尺寸是多少?例如,如何在标签中显示 ProfileImage 对象?

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

推荐答案

ok,答案是:

假设 Twitter 对象是 twitter

Assume that the Twitter object is twitter

1 - 从 twitter 对象中获取用户

1 - get the user from the twitter object

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

2 - 获取个人资料图片网址

2 - get the profile image URL

URL url = user.getProfileImageURL();

3 - 创建图像图标

ImageIcon img = new ImageIcon(url);

4 - 将 JLabel 图标设置为 ImageIcon

4 - set the JLabel icon to be the ImageIcon

Jlabel1.setIcon(img);

这篇关于从 Twitter 检索用户个人资料图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆