Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8942803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:36:35+00:00 2026-06-15T11:36:35+00:00

I am trying to upload and share image using twitter4j library but unable to

  • 0

I am trying to upload and share image using twitter4j library but unable to share this. can anyone please give me a working demo for image sharing on twitter that upload an image share on twitter.. i have searched a lot on google and Stackoverflow but not found suitable answer.
I’ve tried with twitter4j 2.2.5 and 2.1.6 but no luck 🙁
I’ll be thankfull if anyone help me out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:36:37+00:00Added an answer on June 15, 2026 at 11:36 am

    I have solved.. auto import not working for me when i update library i used these libraries

    • twitter4j-core-3.0.2.jar
    • twitter4j-media-support-3.0.2.jar

    these imports

    import oauth.signpost.OAuth;
    import twitter4j.StatusUpdate;
    import twitter4j.Twitter;
    import twitter4j.TwitterException;
    import twitter4j.TwitterFactory;
    import twitter4j.auth.AccessToken;
    import twitter4j.conf.Configuration;
    import twitter4j.conf.ConfigurationBuilder;
    import twitter4j.media.ImageUpload;
    import twitter4j.media.ImageUploadFactory;
    import android.content.SharedPreferences;
    

    and here is the code to share image on twitter

                String token = prefs.getString(OAuth.OAUTH_TOKEN, "");
                String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, "");
    
                AccessToken a = new AccessToken(token, secret);
                Twitter twitter = new TwitterFactory().getInstance();
                twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
                twitter.setOAuthAccessToken(a);
    
                ConfigurationBuilder cb = new ConfigurationBuilder();
                cb.setDebugEnabled(true).setOAuthConsumerKey(yourConsumerKey).setOAuthConsumerSecret(yourConsumerSeceret).setOAuthAccessToken(yourAccessToken).setOAuthAccessTokenSecret(yourAccessTokenSeceret);
    
                Configuration conf = cb.build();
    
                ImageUploadFactory factory = new ImageUploadFactory(conf);
                ImageUpload upload = factory.getInstance();
                String url = upload.upload(yourImage, yourCaptionWithImage); //image is a File Format and Caption is String
    

    upload.upload update your twitter status with image

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to upload an image on facebook. Using this code private void
I'm trying to downsize image uploaded by users at the time of upload. This
I'm trying to upload an image to facebook using the iOS SDK from Facebook.
I'm trying to upload images to a php file, everything works, but sometimes when
I'm trying to upload a rails app to dotcloud. I'm getting this error: PG::Error
So I'm trying to upload a document to a sharepoint site using a Java
I'm trying to upload files to the blobstore in my Google App without using
I'm trying to upload pdf files in the server. And i;m using the following
I'm trying to upload a file .txt in my web space, but then the
I'm trying to upload an image file from an android device to my drupal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.