嗨,我嘗試使用下面的代碼來更新Twitter的狀態,但我不斷收到以下異常, TwitterException {exceptionCode = [bfb606ed-4ef9708b bfb606ed-4ef97061],的StatusCode = - 1,message = null,code = -1,retryAfter = -1,rateLimitStatus = null,version = 3.0.3}連接超時越來越OAuthRequestToken當Twitter的
我已經把正確的消費者「鑰匙」和消費者「祕密」,任何幫助表示讚賞!
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);
}