DirectMessage authentication in Twitter4j API
I am working with a twitter client project which is using the Twitter4j
API. My program is able to read tweets from the timeline, see followers and follower list, but whenever I want to access DirectMessage
it shows
errors:code:93-message:This application is not allowed to
access or delete your direct messages
I have following authentication-
Twitter twitter = new TwitterFactory().getInstance();
twitter.开发者_运维问答setOAuthConsumer(Static.CONSUMER_KEY,Static.CONSUMER_SECRET);
AccessToken accessToken = Static.CURRENT_USER_ACCESS_TOKEN;
twitter.setOAuthAccessToken(accessToken);
twitter = Static.CURRENT_TWITTER;
Any idea what causes the error above?
When access directmessage using twitter4j, an error shows "unable to parse '3577866941' as integer".I have set the value of ACCESS_TOKEN,ACCESSTOKEN_SECRET,CONSUMER_KEY,CONSUMER_SECRET which I got from dev.twitter but it crashes when the application runs.I use twitter4j-core-2.1.8-SNAPSHOT.jar as library.The code is given bellow.
public ResponseList<DirectMessage> dmList=null;
public static AccessToken token = new AccessToken(ACCESS_TOKEN, ACCESSTOKEN_SECRET);
TwitterFactory factory = new TwitterFactory();
twitter = factory.getInstance();
twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
twitter.setOAuthAccessToken(token);
try {
dmList = twitter.getDirectMessages(new Paging(1,15));
} catch (TwitterException e) {
e.printStackTrace();
}
Thanks.
You need "Read, Write and Direct Messages" permission to read / delete direct messages. Make sure that your application is in the appropriate role at https://dev.twitter.com/apps .
精彩评论