Search Facebook by first name with Koala

2019-07-18 07:54发布

问题:

Before, Koala/facebook would let me do this:

graph.search("Ted", {:type => "user"})

Now, it returns an empty array.

It seems one can only search by uncommon or full names now. For example:

graph.search("Ted Turner", {:type => "user"})

...returns results, as does:

graph.search("Lizbeth", {:type => "user"}).

How can I search by first name using Koala?

回答1:

It's possible this is due to the way Facebook handles search results.

Basically, what they do is first they grab the (X) requested results. Second, they filter the results based on privacy (removing users who do not want to be searched). Finally they return what's left.

So suppose Koala's asking for 100 users, and the first 100 users that Facebook finds all have privacy set up to keep themselves hidden; the result will be Facebook returning an empty list and Koala giving you nothing.

Details can be found here: https://developers.facebook.com/blog/post/478/

There are possible solutions, but none of them are really that great: 1) Increase the number of results you request (either through options, or writing an FQL query instead) 2) If you get an empty set of results, immediately use pagination to try calling again, this time asking for the next page. Meaning if you ask for the first 100 users, get nothing, immediately ask for the list of 101-200. Make sure you limit how many times this is done, however, because you probably don't want it to make too many calls.

Neither are great solutions, I know. The fact that you aren't told which entries are missing makes it difficult to get a proper set, so you'll probably have to deal with incomplete lists.