0

I want to get Profile picture from twitter api.

i have tried the following methods .

a) as per this url :Twitter4j authentication credentials are missing and 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()

in this method get 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) as per this latest url

https://dev.twitter.com/docs/api/1.1/get/users/profile_banner

pass screen name of user here :

https://api.twitter.com/1.1/users/profile_banner.json?screen_name=iRohitSachdeva

response: {"errors":[{"message":"Bad Authentication data","code":215}]}.

Community
  • 1
  • 1
Rohit
  • 3,401
  • 4
  • 33
  • 60

1 Answers1

0

The correct thing to do is work out why your authentication data is going wrong.

However, the simple way to get profile images is using a service like http://avatars.io/

For example, the get my avatar, visit http://avatars.io/twitter/edent

It should return the correct URL for my Twitter account's pic.

Terence Eden
  • 14,034
  • 3
  • 48
  • 89