Search code examples
javaandroidtwitterhttprequesttwitter4j

Problems to searchUsers in twitter4j


I'm having trouble searching for users with the searchUsers function of twitter4j, the problem is that the list of users returned is different from the one returned by the endpoint: (https://api.twitter.com/1.1/users/search.json) the above endpoint returns the data correctly, the way I would like it to be with twitter 4j. it is as if twitter4j is only searching for users by focusing on @screenName, if I search for neymar, it shows me several results for neymar, but it will not show me the most relevant profile if not all users with the initials neymar already have been recovered. The documentation says:

"Run a search for users similar to the Find People button on Twitter.com, the same results returned by people search on Twitter.com will be returned by using this API."

Usage note: It is only possible to retrieve the first 1000 matches from this API. ", But this is not the current reality.

my code:

  List<User> = twitter.searchUsers("neymar",10);

note: the list returned by the endpoint (https://api.twitter.com/1.1/users/search.json) brings the users with more relevance. (soon ends up bringing the official profiles which is what I want).


Solution

  • From docs: searchUsers(java.lang.String query, int page) The second parameter is the page, you are looking for page 10, it will soon result in less relevant users, are you sure about this?