tags:

views:

204

answers:

0

Hi people,

i get an "Incorrect signature" error by Twitter Api while im posting an update to my twitter account from my app. I use the javascript OAuth library oauth.js.

Here is my code:

consumer.Name =
{ consumerKey   : "xxxxxxxdwcececwscwdc",
  consumerSecret: "xxrtbujztvfdtcehz5tjv6uvjxbzuku7ik",
  serviceProvider:{  
     signatureMethod     : "HMAC-SHA1"
   , requestTokenURL     : "https://api.twitter.com/oauth/request_token"
   , userAuthorizationURL: "https://api.twitter.com/oauth/authorize"
   , accessTokenURL      : "https://api.twitter.com/oauth/access_token"
   , echoURL             : "myApp.html"
 }
}

function postTweet(consumerName, twitterText){

var accessor = consumer[consumerName];

message = {method: "POST",action: "http://api.twitter.com/1/statuses/update.json", 
parameters:{
   oauth_token: my_oauth_token// <-- here is the current oauth_token
   status: twitterText,
 }
}; // end of message

OAuth.completeRequest(message,
 {
   consumerKey : accessor.consumerKey,
   consumerSecret : accessor.consumerSecret
 }
);



var authorizationHeader = OAuth.getAuthorizationHeader("", message.parameters);
var requestBody = OAuth.formEncode(message.parameters);
var postTweetText = newXMLHttpRequest();
postTweetText.onreadystatechange = function receiveAccessToken(){
if (postTweetText.readyState == 4) {
blabla
}
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
postTweetText.open(message.method, message.action, true);
postTweetText.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

postTweetText.setRequestHeader("Authorization", authorizationHeader);//;

postTweetText.send(requestBody);//requestBody

} }

What am i doing wrong?

}