Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8738737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:47:28+00:00 2026-06-13T10:47:28+00:00

Im using the following method to get all the screen names of users who

  • 0

Im using the following method to get all the screen names of users who are following the authenticated user.

private void getFollowing() {   
     Twitter t = new TwitterFactory().getInstance();
     t.setOAuthConsumer(OAUTH.CONSUMER_KEY, OAUTH.CONSUMER_SECRET);
     aToken = getToken();
     t.setOAuthAccessToken(aToken);
     try {
        long[] friendsID = t.getFriendsIDs(userID, -1).getIDs();
        ResponseList<User> userName = t.lookupUsers(friendsID);
        int count = 0;
        for (User u : userName) {
            count++;
            Log.d("USERNAME : "+ Integer.toString(count), u.getScreenName());
        }
     } catch (TwitterException e) {
        e.printStackTrace();
    }
}

t.lookupUsers(friendsID) causes the following error.

W/System.err(16076): {"errors":[{"code":18,"message":"Too many terms specified in query"}]}

From what I understand, the lookupUsers() method will return info on up to 100 users at a time. Im providing more than that. Could this be why? If so, how can I limit the original request and loop over the remaining users to get all their screennames?

If I’m wrong about why I’m getting the error, what else am I doing wrong?

ANSWER

    private void getFollowing() {   
         Twitter t = new TwitterFactory().getInstance();
         t.setOAuthConsumer(OAUTH.CONSUMER_KEY, OAUTH.CONSUMER_SECRET);
         aToken = getToken();
         t.setOAuthAccessToken(aToken);
         ArrayList<String> names = new ArrayList<String>();
         try {
            int start = 0;
            int finish = 100;
            ArrayList<Long> IDS = new ArrayList<Long>();
            long[] friendsID =  t.getFriendsIDs(userID, -1).getIDs();
            boolean check = true;
            while (check) {
                for (int i=start;i<finish;i++) {
//get first 100     
                    IDS.add(friendsID[i]);
//if at the end, stop
                    if (friendsID.length-1 == i) {
                        check = false;
                        break;                      
                    }
                }
//set values for next 100
                start = start+100;
                finish = finish+100;
                long[] ids = Longs.toArray(IDS);
                ResponseList<User> userName = t.lookupUsers(ids);
//clear so long[] holds max 100 at any given time
                IDS.clear();
                for (User u : userName) {
                    names.add(u.getScreenName());
                }
            }
            String[] screenNames = (String[]) names.toArray(new String[names.size()]);

            ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line, screenNames);
            mPreview.setAdapter(adapter);
         } catch (TwitterException e) {
            e.printStackTrace();
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:47:29+00:00Added an answer on June 13, 2026 at 10:47 am
    private void getFollowing() {   
         Twitter t = new TwitterFactory().getInstance();
         t.setOAuthConsumer(OAUTH.CONSUMER_KEY, OAUTH.CONSUMER_SECRET);
         aToken = getToken();
         t.setOAuthAccessToken(aToken);
         ArrayList<String> names = new ArrayList<String>();
         try {
            int start = 0;
            int finish = 100;
            ArrayList<Long> IDS = new ArrayList<Long>();
            long[] friendsID =  t.getFriendsIDs(userID, -1).getIDs();
            boolean check = true;
            while (check) {
                for (int i=start;i<finish;i++) {
                    //get first 100     
                    IDS.add(friendsID[i]);
                    //if at the end, stop
                    if (friendsID.length-1 == i) {
                        check = false;
                        break;                      
                    }
                }
                //set values for next 100
                start = start+100;
                finish = finish+100;
                long[] ids = Longs.toArray(IDS);
                ResponseList<User> userName = t.lookupUsers(ids);
                //clear so long[] holds max 100 at any given time
                IDS.clear();
                for (User u : userName) {
                    names.add(u.getScreenName());
                }
            }
            String[] screenNames = (String[]) names.toArray(new String[names.size()]);
    
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line, screenNames);
            mPreview.setAdapter(adapter);
         } catch (TwitterException e) {
            e.printStackTrace();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following method to open my SQLite db. private void open() {
greetings all i am using the following method to get the current time in
I am using following method to get bitmap from url but image is not
I am using the following method to get the time of the video with
I am using the following method to serialize a date as a string private
I am using the following method in order to remove all objects from CoreData:
i am using the following method in python to get the X,Y corordinates at
I am using the following method to get data for my jqgrid's subgrid and
As we all know that using GET method for login (or sending sensitive information)
I'm using the following code to get all ClassMetaData from the sessionFactory. ... Map

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.