For 2 days I've tried to do a request with unirest (I have to use it) to Twitter but I'm not getting good feedback from rest of what I'm doing wrong.
This is my request:
HttpResponse request = Unirest.post( "https://api.twitter.com/1.1/account/settings.json" )
.header( "Authorization",
"oauth_consumer_key=\"XXX\"," +
"oauth_token=\"XXX\"," +
"oauth_signature=\"XXX\"" +
"oauth_nonce=\"XXX\"," +
"oauth_signature_method=\"HMAC-SHA1\"," +
"oauth_timestamp=\"1467448738\"," +
"oauth_version=\"1.0\","
)
.header( "Content-Type", "application/json" )
.header( "accept", "application/json" )
.header( "X-Target-URI", "https://api.twitter.com" )
.header( "Host", "api.twitter.com" )
.header( "Connection", "Keep-Alive" ).asJson();
And I'm getting
{"errors":[{"code":215,"message":"Bad Authentication data."}]}
With this page it's easy to do https :// apigee.com/console/twitter but I see oauth_timestamp, oauth_nonce, oauth_signature are random generated every time. (Do I have to generate them somehow?)
http :// quonos.nl/oauthTester/ - this site was helping me to check oauth signature
And this https :// dev.twitter.com/oauth/tools/signature-generator/<+my id> generated for me Signature base string, Authorization header, cURL command
I have also keys from https :// apps.twitter.com/app/ Consumer Key (API Key) Consumer Secret (API Secret) Access Token Access Token Secret (And Access Read, write, and direct messages)
But every time I'm getting an error.
So whats wrong with my code? Do I missing something?
Thanks!