I tried to use Twitter API  to post a tweet using Javascript in a
Google Chrome Extension . Details Below

Base String

POST&http%3A%2F%2Fapi.twitter.com%2F1%2Fstatuses
%2Fupdate.json&oauth_consumer_key%3DXXXXXXXXXXX%26oauth_nonce
%3D9acc2f75c97622d1d2b4c4fb4124632b1273b0e0%26oauth_signature_method
%3DHMAC-SHA1%26oauth_timestamp%3D1305227053%26oauth_token%3D159970118-
XXXXXXXXXXXXXXXXXXXXXXX%26oauth_version%3D1.0%26status%3DHello

Header

OAuth
oauth_nonce="9acc2f75c97622d1d2b4c4fb4124632b1273b0e0",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="1305227053",
oauth_consumer_key="XXXXXXXXXXXXXXXXX",
oauth_token="159970118-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
oauth_signature="IWuyoPJBrfY03Hg5QJhDRtPoaDs%3D",
oauth_version="1.0"

I used POST method with body "status=Hello"

But i get a 500 INTERNAL SERVER ERROR.. IS there any mistake on my
side ??

Javascript code used

h is the header given above

tweet="Hello"

encodeURLall is user defined which is working in all other occasions.

    var xhr = new XMLHttpRequest();
    xhr.open("POST","http://api.twitter.com/1/statuses/update.json";,
false);
    xhr.setRequestHeader("Authorization",h);

    xhr.onreadystatechange = function() {

        if (xhr.readyState == 4 )
        {
                console.log("STATUS="+xhr.status);
                console.log("RESPONSE="+xhr.responseText);
        }
    }

    xhr.send("status="+encodeURLall(tweet));

    }

-- 
Twitter developer documentation and resources: https://dev.twitter.com/doc
API updates via Twitter: https://twitter.com/twitterapi
Issues/Enhancements Tracker: https://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
https://groups.google.com/forum/#!forum/twitter-development-talk

Reply via email to