Twitter4j.getHomeTimeline方法没有检索计数中指定的一定数量的推文

时间:2016-01-05 05:38:34

标签: android twitter4j

当我尝试使用Twitter4j.getHomeTimeline()取出推特状态时,即使我使用分页设置计数,收到的推文数也不一致。

例如如果NO_OF_TWEETS为50,则statuses.size()并不总是50。

        ConfigurationBuilder builder = new ConfigurationBuilder();
        builder.setOAuthConsumerKey(consumerKey);
        builder.setOAuthConsumerSecret(consumerSecret);
        // Access Token
        String access_token = mSharedPreferences.getString(PREF_KEY_OAUTH_TOKEN, "");
        // Access Token Secret
        String access_token_secret = mSharedPreferences.getString(PREF_KEY_OAUTH_SECRET, "");

        AccessToken accessToken = new AccessToken(access_token, access_token_secret);
        Twitter twitter = new TwitterFactory(builder.build()).getInstance(accessToken);

        DbHelper dbHelper = new DbHelper(this);
        db = dbHelper.getWritableDatabase();

        ContentValues values = new ContentValues();
        ResponseList<Status> statuses = null;


        if(maxId != null) {

            Paging page1 = new Paging();
            page1.setCount(NO_OF_TWEETS);
            page1.setMaxId(maxId);
            statuses = twitter.getHomeTimeline(page1);

        }else{

            Paging page1 = new Paging();

            page1.setCount(NO_OF_TWEETS);
            page1.setSinceId(sinceId);
            statuses = twitter.getHomeTimeline(page1);
        }

        Log.d(TAG,"No. of new Statues : "+statuses.size());

0 个答案:

没有答案