我对谷歌的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