Hi, i want to display list of received direct messages and i wrote this code :
ConfigurationBuilder cb1=new ConfigurationBuilder();
cb1.setDebugEnabled(true)
.setOAuthConsumerKey(“XXXXXXXXXXXXXXXX”)
.setOAuthConsumerSecret(“XXXXXXXXXXXXXXX”)
.setOAuthAccessToken(“XXXXXXXXXXXXXXXXXXXXX”)
.setOAuthAccessTokenSecret(“XXXXXXXXXXXXXXXXX”);
try {
TwitterFactory tf=new TwitterFactory(cb1.build());
twitter4j.Twitter tw=tf.getInstance();
Paging paging = new Paging(1);
List<DirectMessage> messages;
do {
messages = ((DirectMessagesResources) tw).getDirectMessages(paging);
for (DirectMessage message : messages) {
System.out.println("From: @" + message.getSenderScreenName() + " --- "
+ message.getText()+" ---- reçu à la date : "+message.getCreatedAt());
}
paging.setPage(paging.getPage() + 1);
} while (messages.size() > 0 && paging.getPage() < 10);
System.out.println("done.");
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to get messages: " + te.getMessage());
System.exit(-1);
}
but it doesn’t work. I had this errors :
Failed to get messages: 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).
message - This application is not allowed to access or delete your direct messages.
code - 93
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).
message - This application is not allowed to access or delete your direct messages.
code - 93
Relevant discussions can be found on the Internet at:
http://www.google.co.jp/search?q=7da221bb or
http://www.google.co.jp/search?q=11fbb269
TwitterException{exceptionCode=[7da221bb-11fbb269], statusCode=403, message=This application is not allowed to access or delete your direct messages., code=93, retryAfter=-1, rateLimitStatus=RateLimitStatusJSONImpl{remaining=14, limit=15, resetTimeInSeconds=1438338113, secondsUntilReset=4371}, version=4.0.4}
at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:164)
at twitter4j.HttpClientBase.request(HttpClientBase.java:57)
at twitter4j.HttpClientBase.get(HttpClientBase.java:75)
at twitter4j.TwitterImpl.get(TwitterImpl.java:1786)
at twitter4j.TwitterImpl.getDirectMessages(TwitterImpl.java:269)
at Mon_Application.messages(Mon_Application.java:300)
at Mon_Application.accueil(Mon_Application.java:112)
at Mon_Application.connexion(Mon_Application.java:83)
at Mon_Application.main(Mon_Application.java:40)
and when i created the developer account i made for permissions : Read, Write and Access direct messages . So why it told me this : This application is not allowed to access or delete your direct messages.
Please I need your help and i wait your answers and thank you very much.