Order users/search by amount of followers


#1

Hello, I am using the users/search API to attempt to find the user that closest matches by search, but has the highest number of followers, I am currently using this command:

$url = 'https://api.twitter.com/1.1/users/search.json';
$getfield = '?q=' . $user . '&page=1&count=1&result_type=popular';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
             ->buildOauth($url, $requestMethod)
           ->performRequest(); 

Which works, but I’d like the one and only result it returns to be the one that not only matches the closest, but has the highest number of followers.

So, for example, if $user = “Bill Gates” and there are, for example, two ‘Bill Gates’ that would have come up in the results (even though I only ask for one), I’d like the one that is returned to be the one with the highest number of followers, hence likely to be the most relevant to my search…

is this possible?

Thank you in advance.


#2

Each user object returned in the list of results has a followers_count json property you can use to sort results - that should work!