我想从twitter api获取个人资料图片。
我尝试了以下方法。
a)根据此网址:Twitter4j authentication credentials are missing和Retrieve the user profile image from twitter
//Twitter Conf.
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey(CONSUMER_KEY)
.setOAuthConsumerSecret(CONSUMER_SECRET)
.setOAuthAccessToken(ACCESS_KEY)
.setOAuthAccessTokenSecret(ACCESS_SECRET);
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
User user = twitter.showUser(id of other user who using same app);
user.getOriginalProfileImageURL()
在此方法中获取异常
08-29 09:05:26.282: W/System.err(3823): 404:The URI requested is invalid or the resource requested, such as a user, does not exists. Also returned when the requested format is not supported by the requested method.
08-29 09:05:26.282: W/System.err(3823): message - Sorry, that page does not exist.
b)根据最新的网址
https://dev.twitter.com/docs/api/1.1/get/users/profile_banner
在此处传递用户的屏幕名称:
https://api.twitter.com/1.1/users/profile_banner.json?screen_name=iRohitSachdeva
回复:{“错误”:[{“message”:“错误验证数据”,“代码”:215}]}。
答案 0 :(得分:0)
正确的做法是找出验证数据出错的原因。
但是,获取个人资料图片的简单方法是使用http://avatars.io/
等服务例如,获取我的头像,访问http://avatars.io/twitter/edent
它应该返回我的Twitter帐户图片的正确网址。