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

  • Home
  • SEARCH
  • 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 8429911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:28:00+00:00 2026-06-10T05:28:00+00:00

I’m currently using Scribe to both authenticate and post non-media messages to Twitter successfully.

  • 0

I’m currently using Scribe to both authenticate and post non-media messages to Twitter successfully. This was very easy, my first test message posted with no issues. However, I can’t seem to post photos at all. I have reviewed Twitter’s instructions for posting with media, both here and here.

All of the Scribe/Twitter examples at Github are for non-media posts. It would be great if someone could provide a solid example of how to post photos to Twitter via Scribe!

I’m have two issues in particular:

1) My posts will not pass authorization. I’ve tried mimicking the examples I posted above, but nothing seems to work.

2) When converting the image from byte[] to a string, I only seem to get 4113 characters before it stops. From my understanding, this is well under the number of characters a String can hold.

Here is how I’m extracting the photo:

// GET PHOTO FILE AND FILE LENGTH
// INSTANTIATE UPLOAD VARIABLE WITH FILE LENGTH

    File file      = new File(photo); // ("photo" is a string path to the photo file)
    int fileLength = (int) file.length();

    uploadFile = new byte[fileLength];

// CREATE BUFFER INPUT STREAM OF FILE

    BufferedInputStream inputStream;

    try {inputStream = new BufferedInputStream(new FileInputStream(file));}
    catch (FileNotFoundException e)
    {
        inputStream = null;
        Toast.makeText(this.getApplicationContext(), "Buffer input stream error!", Toast.LENGTH_LONG).show();
    }

// READ DATA FROM FILE INTO UPLOAD VARIABLE
// CLOSE INPUT STREAM

    try {inputStream.read(uploadFile);}
    catch (IOException e) {Toast.makeText(this.getApplicationContext(), "Read input stream to upload variable error!", Toast.LENGTH_LONG).show();}

    try {inputStream.close();}
    catch (IOException e) {Toast.makeText(this.getApplicationContext(), "Close input stream error!", Toast.LENGTH_LONG).show();}
  • 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-10T05:28:01+00:00Added an answer on June 10, 2026 at 5:28 am

    After a LOT of research and piece milling code from various places I finally figured out what I was doing wrong. Here is an example of how to post photos to Twitter via Scribe OAuth:

    NOTE: This assumes a few things…

    1) You have already saved the photo and have the file path

    2) You have already authenticated the user at some point and have a valid access Token

    3) You MUST add apache-mime4j-0.6.jar & httpmime-4.0.1.jar to you libs folder and include them in your build path!!!

    I really hope this helps someone! It’s very easy to implement, but took a few days of troubleshooting to get it working correctly!

    // BUILD OAUTH SERVICE
    
        OAuthService oAuth = new ServiceBuilder()
            .provider(TwitterApi.class)
            .apiKey(YOUR_TWITTER_API_KEY)        // REPLACE WITH YOUR OWN!!!
            .apiSecret(YOUR_TWITTER_API_SECRET)  // REPLACE WITH YOUR OWN!!!
            .callback(YOUR_CALLBACK)             // REPLACE WITH YOUR OWN!!!
            .build();
    
    // BUILD OAUTH REQUEST & SIGN IT RIGHT AWAY (OTHERWISE MULTIPART FORM MAY PREVENT SIGNING)
    
        OAuthRequest request = new OAuthRequest(Verb.POST, "https://upload.twitter.com/1.1/statuses/update_with_media.json");
        oAuth.signRequest(USER_ACCESS_TOKEN, request);  // ENTER USER'S ACCESS TOKEN
    
    // ADD MULTIPART FORM
    
        try
        {
            MultipartEntity entity = new MultipartEntity();
    
            entity.addPart("status", new StringBody(message));       // THIS IS THE TWITTER MESSAGE
            entity.addPart("media", new FileBody(new File(photo)));  // THIS IS THE PHOTO TO UPLOAD
    
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            entity.writeTo(out);
    
            request.addPayload(out.toByteArray());
            request.addHeader(entity.getContentType().getName(), entity.getContentType().getValue());
        }
        catch (UnsupportedEncodingException e) {e.printStackTrace();}
        catch (IOException e) {e.printStackTrace();}
    
    // SEND REQUEST
    
        try {response = new JSONObject (request.send().getBody());}
        catch (JSONException e) {Log.e("YOUR_APP_TAG", "JSONException Thrown: " + e.getMessage());}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.