How do I send an Ajax request using javascript, to tweet using the access token?


#1

I have access token and access token secret of the user, how do i make an Ajax call to submit a tweet in javascript. I can tweet using C#, but I am not sure how to pass the the required tokes (consumer key, consumer secret, access token and access token secret) through an ajax call.
Following is the code I have, but how do I pass the tokens (I have access to the tokens in this context) here?

$.ajax({
url: 'https://api.twitter.com/1.1/statuses/update.json?status=hello&callback=?’,
dataType: ‘jsonp’,
cache: false,
crossDomain: true,
scriptCharset: “utf-8”,
contentType: “application/json; charset=utf-8”,
success: function (data) {
alert(“successfully tweeted” + " hello");
},
error: function (jqXHR, textStatus, errorThrown) {
alert(“error occurred” + errorThrown + " text status" + textStatus);
}
});


#2

You are discouraged from performing OAuth operations via client-side Javascript. You should perform these requests server-side. If you want the user interaction to be more client-side, the AJAX call should probably be a secure one to your own backend to initiate the tweeting process.


#3

Do you not understand a) this breaks most of the internet, and b) that requires a website to have a backend? What if you’d prefer simple HTML and have all of your processing done on the client side? To use Twitter, now you require some sort of backend script? That seems rather silly to me… Pretty much every other service out there has some sort of read-only API for less complex, display-only purposes (accessible via JSONP or CORS). Twitter used to have it and got big because of it. Now you’re killing this aspect that made Twitter so great.

Please tell me the point in requiring me to connect via OAuth on the server to access my own tweets.