我對谷歌的AppEngine下面的代碼來測試如果Twitter憑證使用twitter4jTwitter4J驗證憑據和追趕的錯誤
public void doGet(HttpServletRequest req, HttpServletResponse resp) {
String Test = "Testing Twitter4J";
try {
ConfigurationBuilder confbuilder = new ConfigurationBuilder();
confbuilder.setOAuthAccessToken("A")
.setOAuthAccessTokenSecret("B")
.setOAuthConsumerKey("C")
.setOAuthConsumerSecret("D");
Twitter twitter = new TwitterFactory(confbuilder.build()).getInstance();
//Status status = twitter.updateStatus("Working lunch today");
User user = twitter.verifyCredentials();
Test = "Successfully updated the status to [" + user.getScreenName() + "].";
} catch (TwitterException e) {
Test = "no";
}
try {
resp.getOutputStream().write(Test.getBytes());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return;
}
如果證書是有效的它按預期工作是有效的。如果我取消訪問,因此證書無效,我得到一個應用程序引擎錯誤:
Uncaught exception from servlet
twitter4j.TwitterRuntimeException: 401:Authentication credentials (https://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid consumer key/secret, access token/secret, and the system clock is in sync.
message - Invalid or expired token
code - 89
Relevant discussions can be found on the Internet at:
http://www.google.co.jp/search?q=93f2523c or
http://www.google.co.jp/search?q=8b74a4e3
TwitterException{exceptionCode=[93f2523c-8b74a4e3], statusCode=401, message=Invalid or expired token, code=89, retryAfter=-1, rateLimitStatus=null, version=3.0.3}
從「用戶的用戶= twitter.verifyCredentials();」線。我期待從javadoc拋出TwitterException: http://twitter4j.org/javadoc/twitter4j/api/UsersResources.html#verifyCredentials() 但似乎我得到一個TwitterRuntimeException。爲什麼?我無法在javadoc中找到任何TwitterRuntimeException的註釋。
Hiii ,,,,你有沒有找到解決方案? @邁克爾.. – 2013-07-29 10:27:59
發現任何解決方案? – 2013-09-11 00:17:21