Can I influence the user/search feature?

user
php
search
api

#1

Hello,

I am using the user/search feature which is working, but not always returning the result I am looking for and I wondered if I could ‘influence’ the search? I’ll explain…

I need to look up the official Twitter account for artists/bands and am performing a search based on the following call (which works fine), but it does not, of course, always return the correct account.

My question is, can I add any search term/filter to, for example, specify that I want results based on interests, such as ‘music’ or ‘entertainment’ to try and narrow down the search and get better results?

$url = 'https://api.twitter.com/1.1/users/search.json';
$getfield = '?q=' . $artist . '&page=1&count=1&result_type=popular';
$requestMethod = 'GET';

Thanks in advance!


#2

Per the documentation, this is a relatively simple search endpoint - however, you can indeed add e.g. interests or topics as additional keywords, which may help.


#3

Hi Andy,

Appreciate your reply, thanks.

Thanks for the link to the documentation, but it does not (that I saw) indicate how to add these keywords?

Looking at the snippet of code that I have, how would I add keywords?

$getfield = '?q=' . $artist . '&page=1&count=1&result_type=popular';

Thanks again, appreciate your help.


#4

You’d add additional space-separated values to the q parameter, so something like:

$getfield = '?q=' . $artist . '%20official%20music&page=1&count=1&result_type=popular';


#5

Hi again Andy, many thanks, I appreciate you taking the time to help mne with this. Thanks!