您好我正在尝试使用以下代码更新 Twitter 状态,但我不断收到以下异常,TwitterException{exceptionCode=[bfb606ed-4ef9708b bfb606ed-4ef97061], statusCode=-1, message=null, code=-1, retryAfter= -1,rateLimitStatus=null,版本=3.0.3}
我已经输入了正确的消费者“密钥”和消费者“秘密”,感谢您的帮助!
public void twitterUpdates(String update) throws TwitterException, IOException {
// The factory instance is re-useable and thread safe.
Twitter twitter = TwitterFactory.getSingleton();
twitter.setOAuthConsumer("key", "secret");
RequestToken requestToken = twitter.getOAuthRequestToken();
AccessToken accessToken = loadAccessToken(twitter.verifyCredentials().getId());
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while (accessToken == null) {
System.out
.println("Open the following URL and grant access to your account:");
System.out.println(requestToken.getAuthorizationURL());
System.out
.print("Enter the PIN(if available) or just hit enter.[PIN]:");
String pin = br.readLine();
try {
if (pin.length() > 0) {
accessToken = twitter
.getOAuthAccessToken(requestToken, pin);
} else {
accessToken = twitter.getOAuthAccessToken();
}
} catch (TwitterException te) {
if (401 == te.getStatusCode()) {
System.out.println("Unable to get the access token.");
} else {
te.printStackTrace();
}
}
}
// persist to the accessToken for future reference.
storeAccessToken(twitter.verifyCredentials().getId(), accessToken);
Status status = twitter.updateStatus(update);
System.out.println("Successfully updated the status to ["
+ status.getText() + "].");
System.exit(0);
}