Twitter OAuth, Error when trying to POST direct message.
Posted
by Darxval
on Stack Overflow
See other posts from Stack Overflow
or by Darxval
Published on 2010-06-03T17:51:55Z
Indexed on
2010/06/03
17:54 UTC
Read the original article
Hit count: 380
So I am building a java script that is used in conjunction of my C++ application for sending direct messages to users. the script does the work of building the request that i send. When i send a request i receive "Incorrect signature" or "can not authenticate you" Does anyone see something i am missing or am doing wrong? I am continuing to investigate. Thank you in advance
Javascript:
var nDate = new Date();
var epoch = nDate.getTime();
var nounce = "";
nounce = Base64.encode(epoch+randomString());
var Parameters = [
"oauth_consumerkey="+sConsumerKey,
"oauth_nonce="+nounce,
"oauth_signature_method=HMAC-SHA1",
"oauth_timestamp="+epoch,
"oauth_token="+sAccessToken,
"oauth_version=1.0",
"text="+sText,
"user="+sUser];
var SortedParameters = Parameters.sort();
var joinParameters = SortedParameters.join("&");
var encodeParameters = escape(joinParameters);
signature_base_string = escape("POST&"+NormalizedURL+"&"+encodeParameters);
signature_key = sConsumerSecret+"&"+sAccessSecret;
signature = Base64.encode(hmacsha1(signature_base_string,signature_key));
sAuthHeader = "
OAuth realm=,
oauth_nonce="+nounce+",
oauth_timestamp="+epoch+",
oauth_consumer_key="+sConsumerKey+",
oauth_signature_method=HMAC-SHA1,
oauth_version=1.0,
oauth_signature="+signature+",
oauth_token="+sAccessToken+",
text="+sText;
goNVOut.Set("Header.Authorization: ", sAuthHeader);
© Stack Overflow or respective owner