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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:16:21+00:00 2026-05-25T23:16:21+00:00

[Update 2011-09-21 11:19] I’ve fixed one problem that was causing a problem and that

  • 0

[Update 2011-09-21 11:19]
I’ve fixed one problem that was causing a problem and that was GMT/GMT+2
My local time is at GMT+2, and twitter is using GMT+0/UTC. This was causing a timestamp out of bounds error.

I’ve now fixed that problem and now facing the next problem:
string(96) “{“request”:”/1/statuses/update_with_media.json”,”error”:”Could not authenticate with OAuth.”}”

This is the request header generated through Themattharris PHP library (using curl):

 ["request_header"]=>
    string(587) "POST /1/statuses/update_with_media.json HTTP/1.1

User-Agent: themattharris' HTTP Client

Host: upload.twitter.com

Accept: */*

Authorization: OAuth oauth_consumer_key="L9AWIB6jvxm3Req1XWHxJA", oauth_nonce="9e41eea04e2dcc2b67784b35c27d8740", oauth_signature="N2Y4YzYwMDg1YjBmZTA1NDgwNDdjOGY3MDI4YjdiNWE3M2E5ZTA5YQ%3D%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1316596483", oauth_token="373846001-bJYH4C47vk34yfIH3XbpvvfZjd2JrIX9OlO5MyO2", oauth_version="1.0"

Content-Length: 10024

Content-Type: multipart/form-data; boundary=----------------------------3ddd9c41c091



"

I am fairly sure that I used the correct secrets (copy-pastaed from the twitter dev pages of my application) There I also generated my private secret token

[Update 2011-09-21 ~10:45]
So I’ve got around using a PHP lib (rewritten to C++/CLI) and my C++ lib now produces the exact same results as the PHP Lib. (The Authorization header string).

For some reason I keep getting a status:(401) Unauthorized.
I am using System.Net.WebClient to make the request. And using UploadValues to, well upload the values.

If I use something like UploadData or using WebRequest instead of WebClient I get a Status:(500) Internal Server error.

I can provide all the strings and headers that I generate if needed (but I of course won’t give out the secrets)

This is for example what my basestring and authorization string look like:

BaseString:
POST&https%3A%2F%2Fupload.twitter.com%2F1%2Fstatuses%2Fupdate_with_media.json&oauth_consumer_key%3DL9AWIB6jvxm3Req1XWHxJA%26oauth_nonce%3Ddb0ca1f6c926c1d3ae0d9cbb2c349ae2%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1316538778%26oauth_token%3D373846001-bJYH4C47vk34yfIH3XbpvvfZjd2JrIX9OlO5MyO2%26oauth_version%3D1.0

Authorization: OAuth oauth_consumer_key=”L9AWIB6jvxm3Req1XWHxJA”,
oauth_nonce=”db0ca1f6c926c1d3ae0d9cbb2c349ae2″,
oauth_signature=”OGI4ZDVkYjZjNjA3YWMyZGYxNWYzZDBhNDE0ODcwMzRkMDE4OWZiYQ%3D%3D”,
oauth_signature_method=”HMAC-SHA1″, oauth_timestamp=”1316538778″,
oauth_token=”373846001-bJYH4C47vk34yfIH3XbpvvfZjd2JrIX9OlO5MyO2″,
oauth_version=”1.0″


Below is the old text, which is not valid any more.


I might be a simple question, but I just can’t figure this out.
I am using Twitterizer to get me the required secret tokens. This library also provides a way to update your twitter with a new tweet, but it does not support the new update_with_media call.

I’ve tried several ways, one way by using WebRequest and the other way by using WebClient (pseudo-C#-code):

string URL = "https://upload.twitter.com/1/statuses/update_with_media.json?oauth_consumer_secret=[mysecretgoeshere]&oauth_token_secret=[usersecretgoeshere]";
System.Net.ServicePointManager.Expect100Continue = false;
Byte[] fileData = File.ReadAllBytes(pathToFile);

#if useWebRequest
    string postString = "status={statusgoeshere}&image[]={Encoding.ASCII.GetString(fileData)}";
    Byte[] postData = Encoding.ASCII.GetBytes(postString);

    WebRequest wr = WebRequest.Create(URL);

    wr.Method = "POST";
    wr.ContentType = "multipart/form-data"; //as required by twitter API
    wr.ContentLength = postData.Length;

    IO.Stream rqstream = wr.GetRequestStream();
    rqstream.Write(postData,0,postData.Length);
    rqstream.Close();

    wr.GetResponse(); //returns status 500 internal server error
#else
    WebClient client = new WebClient();
    NameValueCollection postData = new NameValueCollection();

    postData.Add("status", "{statusgoeshere}");
    postData.add("media[]", Encoding.ASCII.GetString(fileData));

    client.UploadValues(URL, "POST", postData); //returns status 401 not authorized
#endif

I wonder what I am doing wrong (if I am doing something wrong that is). Both ways seem valid in my eyes, but I might be missing some things.

Edit1:
I’ve noticed I am passing the oath parameters in the wrong way, will try and update that part.

  • 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-25T23:16:22+00:00Added an answer on May 25, 2026 at 11:16 pm

    The reason that I haven’t added any file uploads to Twitterizer yet is because it requires modification of the WebRequestBuilder class (that adds the OAuth header and signs requests) to handle multipart POST requests. I have attempted to make the needed modifications to this class a few times, but each time they resulted in instability in the rest of the library, mostly due to lack of documentation on how the Twitter API expects multipart requests to be signed.

    Somewhat recently, however, a document was posted to the Twitter API portal detailing these requests. If you want to try to implement this logic on your own, that will be an invaluable resource. Otherwise, you can wait. I plan on making the modifications soon to properly support file uploads in light of this information.

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

Sidebar

Related Questions

UPDATE 2011.09.13 This bug has been resolved by Adobe. The example code below now
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
EDIT 22 March 2011 : This question is no longer that relevant since Youtube
Update 2011-Jan-06: Believe it or not, I went ahead and incorporated this interface into
Update 2011-12-28: Here's a blog post with a less vague description of the problem
For example I want to update all records to '2012-01-01' ( time : ISODate(2011-12-31T13:52:40Z)
I'm trying to update sales totals in one table using the existing value plus
Update: Check out this follow-up question: Gem Update on Windows - is it broken?
UPDATE: Focus your answers on hardware solutions please. What hardware/tools/add-in are you using to
Using the following steps: (I have checked this similar post , which does not

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.