首页 文章

无法获取用户api 1.1的twitter Profiles 照片

提问于
浏览
0

我想从twitter api获取 Profiles 图片 .

我尝试了以下方法 .

a)根据此网址:Twitter4j authentication credentials are missingRetrieve 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()

在这个方法中得到Exception

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

响应:{“errors”:[{“message”:“Bad Authentication data”,“code”:215}]} .

1 回答

  • 0

    正确的做法是找出验证数据出错的原因 .

    但是,获取配置文件图像的简单方法是使用像http://avatars.io/这样的服务

    例如,获取我的头像,访问http://avatars.io/twitter/edent

    它应该为我的Twitter帐户的图片返回正确的URL .

相关问题