twitter4j_3.0.3无法使用https

时间:2014-01-17 00:48:15

标签: https twitter4j

不幸的是我们的服务器有Java 1.5,它与twitter4j最新版本不兼容。 Twitter最近使用https的变化使我们的应用程序无法运行。我试图通过设置配置来覆盖URL。但它并没有解决问题。请帮忙。

ConfigurationBuilder confBuilder=new ConfigurationBuilder();
confBuilder.setOAuthConsumerKey(consumerKey);
confBuilder.setOAuthConsumerSecret(consumerSecret);
confBuilder.setHttpRetryCount(3);
confBuilder.setHttpRetryIntervalSeconds(30);
confBuilder.setRestBaseURL("https://api.twitter.com/1.1/");
confBuilder.setStreamBaseURL("https://stream.twitter.com/1.1/");
confBuilder.setSiteStreamBaseURL("https://sitestream.twitter.com/1.1/");
confBuilder.setUserStreamBaseURL("https://userstream.twitter.com/1.1/");
confBuilder.setOAuthRequestTokenURL("https://api.twitter.com/oauth/request_token");
confBuilder.setOAuthAccessTokenURL("https://api.twitter.com/oauth/access_token");
confBuilder.setOAuthAuthorizationURL("https://api.twitter.com/oauth/authorize");
confBuilder.setOAuthAuthenticationURL("https://api.twitter.com/oauth/authenticate");
Configuration conf=confBuilder.build();
Twitter twitter=new TwitterFactory(conf).getInstance();

2 个答案:

答案 0 :(得分:1)

不再维护Java 1.5。它在四年前达到了EOL。 您应该升级JVM版本。

答案 1 :(得分:1)

请通过SSL而不是HTTP来尝试此代码

ConfigurationBuilder confBuilder= new ConfigurationBuilder();
confBuilder.setUseSSL(true);

confBuilder.setOAuthRequestTokenURL("https://api.twitter.com/oauth/request_token");
confBuilder.setOAuthAccessTokenURL("https://api.twitter.com/oauth/access_token");
confBuilder.setOAuthAuthorizationURL("https://api.twitter.com/oauth/authorize");
confBuilder.setOAuthAuthenticationURL("https://api.twitter.com/oauth/authenticate");

TwitterFactory Tfactory = new TwitterFactory(builder.build());
Twitter twitter = Tfactory.getInstance();