-1

My code is :

     List<Status> list = new ArrayList<Status>();
     User user;
     Twitter twitter = new Twitter();       
     list = twitter.search(string); 

    for(int i=0; i<list.size();i++){
        user=list.get(i).getUser();
        System.out.print(i+1);
        System.out.println(list.get(i));
        System.out.println(list.get(i).getId());
        System.out.println(list.get(i).getUser());
        System.out.println(user.getId());
        System.out.println(user.getCreatedAt());
        System.out.println(user.getLocation());
        System.out.println(user.getFavoritesCount());
    }

The problem is that good print the status, id of status and user, but user features how user id, location, etc, prints all as null. What I can do to take the features????

Thanks for response

matias
  • 59
  • 4

2 Answers2

0

According to the JTwitter API Docs, calling the default constructor creates a new instance without a user. You need to authenticate with Twitter using Twitter.IHttpClient (which depends on Signpost) to get user data.

Mike Yockey
  • 4,565
  • 22
  • 41
0

The Twitter search method is unusual in that it only returns a small part of the User information. This is a limitation from Twitter & there's nothing you can do about that.

Fields such as location will be blank.

You always get the screen-name, and this can be used to fetch the extra info via the show() method. E.g.

Twitter twitter;
List<String> userNames; // make this list from user.screenName
List<User> fullUserInfo = twitter.users().show(userNames)

If you have an up-to-date copy of JTwitter (http://www.winterwell.com/software/jtwitter.php) it is all in the javadoc.

NB: Other methods sometimes return missing fields in User, if Twitter is experiencing heavy load.

Daniel Winterstein
  • 2,418
  • 1
  • 29
  • 41