1
當我通過我的應用程序發佈更新到我的Twitter帳戶時,我得到Twitter Api的「錯誤簽名」錯誤。 我使用javascript OAuth庫oauth.js。Twitter上的「錯誤簽名」,而使用OAuth.js庫更新/狀態
這裏是我的代碼:
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
} }
我在做什麼錯?
}
你有解決方案嗎?我也遇到了與該庫實際上相同的問題:( – Nachiketha 2013-10-08 07:31:44