Reputation: 3756
I'm trying to get the user ID of a friend using just there name. Coming from a SQl background I figure it would just be something like [Select] [UID] [From] friend [Where] Name = "friends name".
So my query is
$fql_query_url = 'https://graph.facebook.com/'
. 'fql?q=SELECT+uid+FROM+friend+WHERE+name=Friends Name'
. '&access_token=' . $access_token;
What's the error in my logic here?
Upvotes: 0
Views: 1174
Reputation: 4466
Instead of friend
FQL table you should use user
table to retrieve the uid
of your friend against his/her name. This is because the friend
table just stores the relationship between two user
and not detail about them.
So your query should be as following
SELECT uid
FROM user
where name = "Name" and uid in (select uid2 from friend where uid1 = me())
And as the name
field is not indexable we need to filter the users in user
table using uid2
from friend
table.
Edit
Your query needs to be changed to following to work
$fql_query_url = 'https://graph.facebook.com/fql?'
. 'q=SELECT+uid+FROM+user+where+name+%3D+%27User+Name%27+'
. 'and+uid+in+%28select+uid2+from+friend+where+uid1+%3D+me%28%29%29'
. '&access_token=' . $access_token;
Upvotes: 1