我正在开发一个android应用程序来获得twitter关注者。下面的代码用于身份验证,我已经成功登录。

consumer = new CommonsHttpOAuthConsumer(
                        key,
                        secret);
                CommonsHttpOAuthProvider provider = new CommonsHttpOAuthProvider(
                        "http://twitter.com/oauth/request_token",
                        "http://twitter.com/oauth/access_token",
                        "http://twitter.com/oauth/authorize");

                String authUrl = provider.retrieveRequestToken(consumer,
                        TWITTER_CALLBACK_URL);
                Log.e("Twittwer ", "Please authorize this app!");

                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse(authUrl)));

为了得到追随者的名单,我使用了下面的代码,但我发现了错误,并附上了logcat
AccessToken accessToken = new AccessToken(consumer.getToken(),
                    consumer.getTokenSecret());
            ConfigurationBuilder builder = new ConfigurationBuilder();
            builder.setOAuthConsumerKey(key);
            builder.setOAuthConsumerSecret(secret);
            Configuration conf = builder.build();
            twitter = new TwitterFactory(conf).getInstance();
            twitter.setOAuthAccessToken(accessToken);
            IDs followersId = twitter.getFollowersIDs(twitter.getId());
            do {
                for (long i : followersId.getIDs()) {



                    System.out.println("follower ID #" + i);
                    System.out.println(twitter.showUser(i).getName());
                    System.out.println(twitter.showUser(i)
                            .getProfileImageURL());
                    System.out.println(twitter.showUser(i).getURL());

                }
            } while (followersId.hasNext());
        } catch (TwitterException e) {
            System.out.println("e........"+e.getMessage());
            e.printStackTrace();

        }

LogCAT:
02-18 16:13:10.632: W/System.err(734): Received authentication challenge is null 02-18 16:13:10.682: W/System.err(734): Relevant discussions can be found on the Internet at: 02-18 16:13:10.682: W/System.err(734):    http://www.google.co.jp/search?q=a1259409 or 02-18 16:13:10.702: W/System.err(734):     http://www.google.co.jp/search?q=06b97274 02-18 16:13:10.712: W/System.err(734): TwitterException{exceptionCode=[a1259409-06b97274 2e9324ac-d074d7d2], statusCode=-1, message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=3.0.3} 02-18 16:13:10.752: W/System.err(734):     at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:192) 02-18 16:13:10.903: W/System.err(734):   at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:61) 02-18 16:13:11.012: W/System.err(734):  at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:89) 02-18 16:13:11.062: W/System.err(734):  at twitter4j.TwitterBaseImpl.fillInIDAndScreenName(TwitterBaseImpl.java:126) 02-18 16:13:11.123: W/System.err(734):     at twitter4j.TwitterBaseImpl.getId(TwitterBaseImpl.java:118) 02-18 16:13:11.142: W/System.err(734):     at com.nest.twitterfriendsfinder.MainActivity$getFollowers.doInBackground(MainActivity.java:276) 02-18 16:13:11.152: W/System.err(734):     at com.nest.twitterfriendsfinder.MainActivity$getFollowers.doInBackground(MainActivity.java:1) 02-18 16:13:11.192: W/System.err(734):   at android.os.AsyncTask$2.call(AsyncTask.java:264) 02-18 16:13:11.212: W/System.err(734):   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 02-18 16:13:11.232: W/System.err(734):    at java.util.concurrent.FutureTask.run(FutureTask.java:137) 02-18 16:13:11.302: W/System.err(734):  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208) 02-18 16:13:11.362: W/System.err(734):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 02-18 16:13:11.362: W/System.err(734):   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 02-18 16:13:11.362: W/System.err(734):   at java.lang.Thread.run(Thread.java:856) 02-18 16:13:11.362: W/System.err(734): Caused by: java.io.IOException: Received authentication challenge is null 02-18 16:13:11.372: W/System.err(734):    at libcore.net.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:397) 02-18 16:13:11.372: W/System.err(734):  at libcore.net.http.HttpURLConnectionImpl.processResponseHeaders(HttpURLConnectionImpl.java:345) 02-18 16:13:11.372: W/System.err(734):     at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:276) 02-18 16:13:11.372: W/System.err(734):    at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:479) 02-18 16:13:11.372: W/System.err(734):    at twitter4j.internal.http.HttpResponseImpl.<init>(HttpResponseImpl.java:34) 02-18 16:13:11.382: W/System.err(734):     at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:156)

这段代码中有什么问题。我在Emulator中读到了一些检查时间戳的帖子。但是Emulator中的时间和日期是正确的。请提供一些帮助。提前谢谢。
[编辑]
this对吧?

最佳答案

在我的项目中,我有这个代码是为了吸引追随者。
也许主要的一点与使用AsyncTask有关。

    if (twitter == null){
        ConfigurationBuilder builder = new ConfigurationBuilder();
        Configuration conf = builder
        .setOAuthConsumerKey(CONSUMER_KEY)
        .setOAuthConsumerSecret(CONSUMER_SECRET)
        .setOAuthAccessToken(oAuthAccessToken)
        .setOAuthAccessTokenSecret(oAuthAccessTokenSecret)
        .build();
        twitter = new TwitterFactory(conf).getInstance();
    }


    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            long lCursor = -1;
            AccessToken accessToken = new AccessToken(oAuthAccessToken, oAuthAccessTokenSecret);
            long userId = accessToken.getUserId();
            try {
                IDs followersIDs = twitter.getFollowersIDs(userId, lCursor);
                do {
                    for (long i : friendsIDs.getIDs()){
                        Log.d("follower ID #", String.valueOf(i));
                    }
                }while(followersIDs.hasNext());
            } catch (TwitterException e) {
                Log.i("fetchFollowers", e.getErrorMessage());
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void param) {
        }

    }.execute();

10-07 17:17