1

I want to implement the Twitter in My Application. With that, i want to Upload the Photo on it. I also want to use the default Auth of the Twitter then Which one is the Best way to post photo on one button click and get message that the photo is posted on twitter.

I want any Simple Demo that help me for my application.

Thanks.

Shreyash Mahajan
  • 23,386
  • 35
  • 116
  • 188
  • check out this link.. http://stackoverflow.com/questions/7609656/can-we-post-image-on-twitter-using-twitter-api-in-android – Mitesh Jain Dec 02 '11 at 06:33

1 Answers1

3

you can use this following link

this

and please so this below method in that

 public String postPicture(String fileName) {

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    String provider = preferences.getString("pictureService","yfrog");

    try {
        File file = new File(fileName);
        MediaProvider mProvider ;
        if (provider.equals("yfrog"))
            mProvider = MediaProvider.YFROG;
        else if (provider.equals("twitpic"))
            mProvider = MediaProvider.TWITPIC;
        else
            throw new IllegalArgumentException("Picture provider " + provider + " unknown");

        String accessTokenToken = account.getAccessTokenKey();
        String accessTokenSecret = account.getAccessTokenSecret();

        Properties props = new Properties();
        props.put(PropertyConfiguration.MEDIA_PROVIDER,mProvider);
        props.put(PropertyConfiguration.OAUTH_ACCESS_TOKEN,accessTokenToken);
        props.put(PropertyConfiguration.OAUTH_ACCESS_TOKEN_SECRET,accessTokenSecret);
        props.put(PropertyConfiguration.OAUTH_CONSUMER_KEY,TwitterConsumerToken.consumerKey);
        props.put(PropertyConfiguration.OAUTH_CONSUMER_SECRET,TwitterConsumerToken.consumerSecret);
        Configuration conf = new PropertyConfiguration(props);

        ImageUploaderFactory factory = new ImageUploaderFactory(conf);
        ImageUpload upload = factory.getInstance(mProvider);
        String url = upload.upload(file);
        return url;
    } catch (Exception e) {
        e.printStackTrace(); // TODO: Customise this generated block
    }
    return null;
}
Hardik Gajjar
  • 5,038
  • 8
  • 33
  • 51