Making authenticated calls on Twitter can be a pain.
Ensure that the parameters in the signature baseline are alphabetically ordered.
Take this:
oauth_consumer_key={consumerkey}&oauth_nonce={nonce}&oauth_signature_method=HMAC-SHA1&oauth_timestamp={timestamp}&oauth_token={token}&oauth_version=1.0&status={tweet text}
fill in the values, encode them in Base64 and then connect them as follows:
POST&{base64 encoded url}&{base64 encoded base string}
it will be the string to be signed (without brackets). (In this case, the URL will be https://api.twitter.com/1.1/statuses/update.json )
The signing key should be constructed as follows:
{consumer secret}&{token secret}
The signature is an HMACSHA1 hash, which is then encoded by base64.
Then you need to put this in the authorization header:
OAuth oauth_consumer_key="{consumer key}",oauth_nonce="{nonce}",oauth_signature="{signature}",oauth_signature_method="HMAC-SHA1",oauth_timestamp="{timestamp}",oauth_token="{token}",oauth_version="1.0"
Finally, put status=your tweet text as the published data in your request.
Hope this helps.
source share