当使用twitter api时,我就是这样的

时间:2016-01-30 04:49:09

标签: twitter

代码:

 public static void main(String[] args) {
        try {
            ConfigurationBuilder builder = new ConfigurationBuilder();
            builder.setOAuthConsumerKey(TestTwitter.CONSUMER_KEY);
            builder.setOAuthConsumerSecret(TestTwitter.CONSUMER_SECRET);
            builder.setOAuthAccessToken(TestTwitter.ACCESS_TOKEN);
            builder.setOAuthAccessTokenSecret(TestTwitter.ACCESS_TOKEN_SECRET);
            TwitterFactory factory = new TwitterFactory(builder.build());
            Twitter twitter = factory.getSingleton();
            long cursor = -1;
            IDs ids;
            System.out.println("Listing following ids.");
            do {
                ids = twitter.getFriendsIDs("twitterapi&amp", cursor);
                for (long id : ids.getIDs()) {
                    System.out.println(id);
                }
                if (0 < args.length) {
                    ids = twitter.getFriendsIDs("twitterapi&amp", cursor);
                } else {

              ids = twitter.getFriendsIDs(cursor);
                }
                for (long id : ids.getIDs()) {
                    System.out.println(id);
                }
            } while ((cursor = ids.getNextCursor()) != 0);
            System.exit(0);
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to get friends' ids: " + te.getMessage());
            System.exit(-1);
        }
    }

异常:错误

相关讨论可在互联网上找到:

http://www.google.co.jp/search?q=a0c96a69

http://www.google.co.jp/search?q=167f39ca

TwitterException{exceptionCode=[a0c96a69-167f39ca 1f2c9ed7-b967fb3d], statusCode=-1, message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=4.0.4}
    at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:179)
    at twitter4j.HttpClientBase.request(HttpClientBase.java:57)
    at twitter4j.HttpClientBase.get(HttpClientBase.java:75)
    at twitter4j.TwitterImpl.get(TwitterImpl.java:1786)
    at twitter4j.TwitterImpl.getFriendsIDs(TwitterImpl.java:351)
    at GetFriendsIDs.main(GetFriendsIDs.java:54)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.net.SocketTimeoutException: connect timed out
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
    at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
    at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1105)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:999)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1513)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
    at twitter4j.HttpResponseImpl.<init>(HttpResponseImpl.java:35)
    at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:143)
    ... 10 more

现在我不知道该怎么办,可以帮忙吗?

0 个答案:

没有答案