I try to send signed oAuth XMLHttpRequest from background page from my
extension to ttp://
api.twitter.com/1/statuses/update.json, but there
are no response from twitter, but all of the previous oAuth dance
steps successfully finished. It looks like a xhr just hangs or totally
close the connection before the answer received. For oAuth i use
popular library for JS -
http://oauth.googlecode.com/svn/code/javascript/
from John Kristian. It was adviced on
oauth.net
Twitter Api successfully gives me all the tokens (i use oAuth OOB) the
twitter
returns me a PIN code, then it successfully changed to acces token,
and on the final stage - attemp to update status it doesnt return any
response (((
I try to send Authorization header (i think, all right with it), and
i
try to send authorization fields directly in POST body, but nothing
((
My code is :
message = {method: "post", action: "
http://api.twitter.com/1/statuses/
update.json",
parameters: [["status","Yahoo"]]};
var requestBody = OAuth.formEncode(message.parameters);
OAuth.completeRequest(message,
{ consumerKey : accessor.consumerKey
, consumerSecret: accessor.consumerSecret
, token : token
, tokenSecret : token_secret
});
var authorizationHeader = OAuth.getAuthorizationHeader("",
message.parameters);
var requestAction = new XMLHttpRequest();
requestAction.onreadystatechange = function() {
if (requestAction.readyState == 4) {
alert(requestAction.status+" "+requestAction.statusText
+"\n"+requestAction.getAllResponseHeaders()
+"\n"+requestAction.responseText);
}
};
requestAction.open(message.method, message.action, true);
requestAction.setRequestHeader("Authorization", authorizationHeader);
requestAction.setRequestHeader("Content-Type", "application/x-www-
form-
urlencoded");
requestAction.send(requestBody);