I want to know how to update my status with upload media on twitter using java. Currently my code is able to post the text status but when the same is being used with media upload, am receiving response
459Authorization Required `{"errors":[{"code":32,"message":"Could not authenticate you."}]}`
code :
File file = new File("/tmp/abc.png");
OAuthConsumer oAuthConsumer = new CommonsHttpOAuthConsumer(consumerKey,consumerSecret);
oAuthConsumer.setTokenWithSecret(accessToken, accessTokenSecret);
HttpPost httpPost = new HttpPost("https://api.twitter.com/1.1/statuses/update.json?media_data="+Base64.encodeBase64(FileUtils.readFileToByteArray(file)));
oAuthConsumer.sign(httpPost);
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpResponse httpResponse = httpClient.execute(httpPost);
int statusCode = httpResponse.getStatusLine().getStatusCode();
System.out.println(statusCode + ':'+ httpResponse.getStatusLine().getReasonPhrase());
System.out.println(IOUtils.toString(httpResponse.getEntity().getContent()));
I’ve googled for my solution but found apis like Twitter4j, spring social integration etc but my application does not need them at this stage.
Any help / tutorial that shows Post Status With media(image) on JAVA ?