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 7546053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:05:59+00:00 2026-05-30T09:05:59+00:00

I had successfully integrate twitter API and I am able to post text from

  • 0

I had successfully integrate twitter API and I am able to post text from my device but I want to know two things

  1. Is is possible to post Image on twitter using API in Android ?

  2. In twitter we used OAuth.OAUTH_TOKEN and OAuth.OAUTH_TOKEN_SECRET tokens.I passing token values on second argument in below code is it ok ? or I have to leave it blank ?

    String token = prefs.getString(OAuth.OAUTH_TOKEN, OAuth_token_key);
    String secret = prefs.getString(OAuth.OAUTH_TOKEN_SECRET, OAuth_token_secret);
    

I searched to know whether is it possible to post image on twitter using twitter API in Android but I have not found any link that I know whether it is possible or not.

I got one similar post image issue for iPhone and there is a answer also. I don’t know about iPhone so I can’t know weather it is right answer or not.Here is a link of similar question of post image for iPhone

Please help me out from this issue.

  • 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-05-30T09:06:00+00:00Added an answer on May 30, 2026 at 9:06 am

    Yes You can post the Image on the Twitter.

    AIK, there are two methods to upload the photo to the Twitter.

    With First you have to implemente the Twitter API and use this Link to upload the Photot to the Twitter.

    Sorry for the Example. as i dont get any example for how to use this.

    With Second you can do this with the help of the twitPic4j API.
    Just add the API for twitPic4j and write below code to upload the photo.

    Code:

    File picture = new File(APP_FILE_PATH + "/"+filename+".jpg");  
    // Create TwitPic object and allocate TwitPicResponse object 
    TwitPic tpRequest = new TwitPic(TWITTER_NAME, TWITTER_PASSWORD); 
    TwitPicResponse tpResponse = null;  
    // Make request and handle exceptions                            
    try {         
            tpResponse = tpRequest.uploadAndPost(picture, customMessageEditText.getText()+" http://www.twsbi.com/");
    
    } 
    catch (IOException e) {         
            e.printStackTrace(); 
           Toast.makeText(getApplicationContext(), "Please enter valid username and password.", Toast.LENGTH_SHORT).show();
    } 
    catch (TwitPicException e) {         
            e.printStackTrace(); 
            Toast.makeText(getApplicationContext(), "Invalid username and password.", Toast.LENGTH_SHORT).show();
            Toast.makeText(getApplicationContext(), "Please enter valid Username and Password.", Toast.LENGTH_SHORT).show();
    }  
    // If we got a response back, print out response variables                               
    if(tpResponse != null) {         
           tpResponse.dumpVars();
           System.out.println(tpResponse.getStatus());
           if(tpResponse.getStatus().equals("ok")){
                Toast.makeText(getApplicationContext(), "Photo posted on Twitter.",Toast.LENGTH_SHORT).show();
                //picture.delete();
           }
     }
    

    Above code works in for my case.

    Hope you got the sollution with the second one and i dont know how to use the first one.

    Enjoy. 🙂

    Updated

    If still it not works for you and try some project listed below:

    Example 1

    Example 2

    Example 3

    Example 4

    Hope that will help you.

    Happy Coding.

    ==================================

    FOR erdomester and Updated answer

    ==================================

    Please check my first link given with Example1 and its api: Twitter4J
    So, if any library that stop giving functionality to upload image on twitter, you can use other library for same. Please check and read regrading Twitter4j.

    Check Twitter4J API to upload file to Twitter: Twitter4j Image Upload

    For instance help you can also check below code to upload image file on Twitter.

    Code to upload Image:

        /**
     * To upload a picture with some piece of text.
     * 
     * 
     * @param file The file which we want to share with our tweet
     * @param message Message to display with picture
     * @param twitter Instance of authorized Twitter class
     * @throws Exception exception if any
     */
    
    public void uploadPic(File file, String message,Twitter twitter) throws Exception  {
        try{
            StatusUpdate status = new StatusUpdate(message);
            status.setMedia(file);
            twitter.updateStatus(status);}
        catch(TwitterException e){
            Log.d("TAG", "Pic Upload error" + e.getErrorMessage());
            throw e;
        }
    }
    

    I hope this will help you more for your query.

    Thanks to eredomester to notify me that tweetpic is no more working for Twitter. But please dont do downvote to answer untill you have not fully search on the given reply. Given library Twitter4J in Example1 gives clear idea about uploading image to twitter and you can easily implement it.

    For more help and code you can also check: Twitter Upload media

    Note: To use this please make sure you have latest jar file. I have used twitter4j-core-2.2.5.jar or more for this.

    Please comment me instead of downvoting this answer, if you facing any issue in this.

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

Sidebar

Related Questions

I know how to share a text viz twitter,i used this code to integrate
I had configured JSF 1.2 successfully to display English error messages that come from
I had download and compiled the source code from GIT, and also successfully runs
I had started working on GPGPU some days ago and successfully implemented cholesky factorization
Had a good search here but can't see anything that gets my mind in
I had to delete all the rows from a log table that contained about
I had successfully installed CKeditor plugin on a textarea in Html view in a
I need to run several functions at the same time. I had successfully implemented
I have successfully had a jQuery UI effect take place on a page using
I had the stand-alone app that was able to show the map using the

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.