I am using twitter4j-core-4.0.4.jar.
This is my code
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setUserStreamRepliesAllEnabled(true);
builder.setOAuthConsumerKey("myConusmerKey");
builder.setOAuthConsumerSecret("myConsumerSecret");
AccessToken accessToken = new AccessToken(pref.getString("ACCESS_TOKEN", ""), pref.getString("ACCESS_TOKEN_SECRET", ""));
Twitter twitter = new TwitterFactory(builder.build()).getInstance(accessToken);
File file = new File(picturePath);
StatusUpdate statusUpdate = new StatusUpdate(messageText.getText().toString());
Uri uri = Uri.parse(picturePath);
InputStream is = ScribbleFragment.this.getContentResolver().openInputStream(uri);
Log.d("Logger", "Sending media");
statusUpdate.setMedia(picturePath, is);
Log.d("Successfully sent media", "Sent media");
status = twitter.updateStatus(statusUpdate);
return status.toString();
This is the response i am getting, i googled it but i didn’t find any answer
W/System.err: Failed to search tweets: 403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (https://support.twitter.com/articles/15364-about-twitter-limits-update-api-dm-and-following). W/System.err: message - Error creating status. W/System.err: code - 189
2
Answers
https://en.wikipedia.org/wiki/HTTP_403
This probably has to do something with you access credentials. Check on how you get the access token and make sure it’s valid, since 403 is usually an error meaning you’re not authorized (forbidden) to access the data.
I think you are setting your Consumer Key and Consumer Secret incorrectly. You should be setting them to the values from Twitter (or calling getString to retrieve them). At the moment they are both hard-coded to a value that looks incorrect.