我能夠使用twitter4j登錄到twitter並獲取登錄用戶的信息,但我無法從我的應用程序發佈推文。我正在使用java web應用程序發佈推文。看到我使用的下面的代碼。如何在java中使用twitter4j發佈推文?
String ACCESS_TOKEN = "ttttttttt";
String ACCESS_TOKEN_SECRET = "gggggggggggggg";
String CONSUMER_KEY = "gggggggggggg";
String CONSUMER_SECRET = "hhhhhhhhhhhhh";
String tweet = "";
if (request.getParameter("tweet") != null) {
tweet = request.getParameter("tweet");
}
AccessToken accessToken = new AccessToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
OAuthAuthorization authorization = new OAuthAuthorization(ConfigurationContext.getInstance(), CONSUMER_KEY, CONSUMER_SECRET, accessToken);
Twitter twitter = new TwitterFactory().getInstance(authorization);
try {
//twitter.updateStatus("Hello World!");
twitter.updateStatus(tweet);
} catch (TwitterException e) {
System.err.println("Error occurred while updating the status!");
}
我得到的follwing異常:
TwitterException {exceptionCode = [fa54b184-3bf2623f],的StatusCode = 401,retryAfter = 0,rateLimitStatus = NULL,版本2.1.5 =-SNAPSHOT(構建:d372a51b9b419cbd73d416474f4a855f3e889507 )}
請幫忙。