How to get list of all twitter followers using twitter4j?

后端 未结 4 786
情书的邮戳
情书的邮戳 2021-01-16 15:01

I have been wondering if there is a way to access all the twitter followers list.

We have tried using call to the REST API via twitter4j:

  public Li         


        
4条回答
  •  -上瘾入骨i
    2021-01-16 15:56

    Try This...

     ConfigurationBuilder confbuilder = new ConfigurationBuilder();
        confbuilder.setOAuthAccessToken(accessToken)
                .setOAuthAccessTokenSecret(secretToken)
                .setOAuthConsumerKey(TwitterOAuthActivity.CONSUMER_KEY)
                .setOAuthConsumerSecret(TwitterOAuthActivity.CONSUMER_SECRET);
        Twitter twitter = new TwitterFactory(confbuilder.build()).getInstance();
    
        PagableResponseList followersList;
    
        ArrayList list = new ArrayList();
        try
        {
            followersList = twitter.getFollowersList(screenName, cursor);
    
            for (int i = 0; i < followersList.size(); i++)
            {
                User user = followersList.get(i);
                String name = user.getName();
                list.add(name);
                System.out.println("Name" + i + ":" + name);
            }
    
            listView.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1 , list));
            listView.setVisibility(View.VISIBLE);
            friend_list.setVisibility(View.INVISIBLE);
            post_feeds.setVisibility(View.INVISIBLE);
            twit.setVisibility(View.INVISIBLE);
        }
    

提交回复
热议问题