matheus.rocha89
matheus.rocha89

Reputation: 309

Get just the female or male friends

I'm developing an facebook application. In this app I get the friends of the user using the graph api. For example:

$facebook->api("/{$user_id}/friends?fields=id,name,gender");

This works fine, but I want to filter to get just the male, or just the female friends. I'm doing this by getting all the friends of the user and then selecting the males or females, but I want to know if there is a way to filter that at the time of the api call. Can someone help me?

Upvotes: 1

Views: 3103

Answers (1)

Botanick
Botanick

Reputation: 663

Try to use FQL:

/fql?q=select uid, name, sex from user where uid in(select uid2 from friend where uid1 = me()) and sex = "female"

FB dev explorer example

Upvotes: 2

Related Questions