tags:

views:

103

answers:

2

What Facebook API call should I make in order to find new friends by First and Last name?

The functionality that I'm trying to achieve is similar to Find Friends page, but I have to do that programmatically.

Many thanks in advance.

Sincerely,

Roman

+2  A: 

There is no specific API call that will get you that kind of data, however, you can use fql.query to query Facebook directly using FQL.

I think the query you want would look something like this:

SELECT uid FROM user WHERE strpos("Chris", first_name) = 0 
AND uid IN (SELECT uid2 FROM friend WHERE uid1 = 123456 )

where the uid1 value is the Facebook ID of the person who's friends you're looking for. You could filter that result set by adding additional clauses to the WHERE that compared to fields available from the user FQL table.

zombat
A: 

If you are thinking of implementing something like a typeahead widget, FQL queries are going to be much too slow to do in between user keystrokes.

This query can be run when you first render your page to get you the names of all the user's friends to embed this information in javascript for the initial page load.

select uid, first_name, last_name from user where uid in
(select uid2 from friend where uid1 = 123456);
teepark