疑难解答谢谢
我不确定为什么不。
可能是https问题。
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true).setOAuthConsumerKey("***************************")
.setOAuthConsumerSecret("***************************");
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
request.getSession().setAttribute("twitter",twitter);
g_reqToken = twitter.getOAuthRequestToken(); `<------------------error line`
authUrl = g_reqToken.getAuthorizationURL();
request.getSession().setAttribute("userToken",g_reqToken.getToken());
request.getSession().setAttribute("userSecretToken",g_reqToken.getTokenSecret());
DEBUG [http-bio-80-exec-6](AbstractHandlerExceptionResolver.java:132) - 解决处理程序的异常[web.controller.snsTest@33a5d1ee]:api.twitter.com 相关讨论可在互联网上找到: http:/ /www.google.co.jp/search?q=3cc69290或 http:/ /www.google.co.jp/search?q=161493db TwitterException {exceptionCode = [3cc69290-161493db 3cc69290-161493b1],statusCode = -1,message = null,code = -1,retryAfter = -1,rateLimitStatus = null,version = 4.0.2} DEBUG [http-bio-80-exec-6](AbstractHandlerExceptionResolver.java:132) - 解决处理程序中的异常[web.controller.snsTest@33a5d1ee]:api.twitter.com 相关讨论可在互联网上找到: http:/ /www.google.co.jp/search?q=3cc69290或 http:/ /www.google.co.jp/search?q=161493db TwitterException {exceptionCode = [3cc69290-161493db 3cc69290-161493b1],statusCode = -1,message = null,code = -1,retryAfter = -1,rateLimitStatus = null,version = 4.0.2} DEBUG [http-bio-80-exec-6](AbstractHandlerExceptionResolver.java:132) - 解决处理程序中的异常[web.controller.snsTest@33a5d1ee]:api.twitter.com 相关讨论可在互联网上找到: http://www.google.co.jp/search?q=3cc69290或 http://www.google.co.jp/search?q=161493db TwitterException {exceptionCode = [3cc69290-161493db 3cc69290-161493b1],statusCode = -1,message = null,code = -1,retryAfter = -1,rateLimitStatus = null,version = 4.0.2} DEBUG [http-bio-80-exec-6](FrameworkServlet.java:959) - 无法完成请求 api.twitter.com 相关讨论可在互联网上找到: http:/ /www.google.co.jp/search?q=3cc69290或 http:/ /www.google.co.jp/search?q=161493db TwitterException {exceptionCode = [3cc69290-161493db 3cc69290-161493b1],statusCode = -1,message = null,code = -1,retryAfter = -1,rateLimitStatus = null,version = 4.0.2} 在twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:178) 在twitter4j.HttpClientBase.request(HttpClientBase.java:53) 在twitter4j.HttpClientBase.post(HttpClientBase.java:82) 在twitter4j.auth.OAuthAuthorization.getOAuthRequestToken(OAuthAuthorization.java:107) 在twitter4j.auth.OAuthAuthorization.getOAuthRequestToken(OAuthAuthorization.java:92) 在twitter4j.TwitterBaseImpl.getOAuthRequestToken(TwitterBaseImpl.java:263) 在twitter4j.TwitterBaseImpl.getOAuthRequestToken(TwitterBaseImpl.java:258) 在web.controller.snsTest.twitter(snsTest.java:96) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) 在org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) 在org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440) 在org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428) 在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) 在org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) 在org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936) 在org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:646) 在org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 在org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 在cms.common.SimpleCORSFilter.doFilter(SimpleCORSFilter.java:19) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 在org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) 在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 在org.apache.logging.log4j.core.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:66) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) 在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) 在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) 在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 在org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) 在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) 在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) 在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070) at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:611) at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:314) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:615) at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61) 在java.lang.Thread.run(Thread.java:745) 引起:java.net.UnknownHostException:api.twitter.com 在java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178) 在java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) 在java.net.Socket.connect(Socket.java:579) 在sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:618) 在sun.net.NetworkClient.doConnect(NetworkClient.java:175) 在sun.net.www.http.HttpClient.openServer(HttpClient.java:432) 在sun.net.www.http.HttpClient.openServer(HttpClient.java:527) 在sun.net.www.protocol.https.HttpsClient。(HttpsClient.java:275) 在sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:371) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:932) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1091) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250) 在twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:136) ... 51更多
答案 0 :(得分:0)
我遇到了同样的错误,但是一旦我切换到wifi,一切都按预期工作......当网络连接是一周时,我有这种与twitter4j不同的问题。