How to Filter facebook friends by age using Graph API

I want to filter friends of the current user by their age. Is this possible using FQL? If so, what would the query look like?

-- EDIT --

An example of the kind of filtering im looking at is:

Find all friends between the age of 20-30

Answers


This will list your friends along with their birthdays. You can simply modify it to display pages fans:

fql?q=SELECT uid, birthday_date FROM user where uid IN (select uid2 from friend WHERE uid1=me() ) order by birthday_date DESC

First calculate the years in whatever language you're using e.g. in JavaScript (see below), and then get the year out of the birthday_date field using substr() and compare them. Note that access to the birthday_date field requires the friends_birthday permission.

var year = new Date().getFullYear();
var twentyYearsAgo = year - 20,
  thirtyYearsAgo = year - 30;

var query = "SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND substr(birthday_date,6,10) > " + thirtyYearsAgo + " AND substr(birthday_date,6,10) < " + twentyYearsAgo";

Need Your Help

Tomcat Stress Test Timeout

java web-services tomcat tomcat6

I'm currently investigating issues on the following system: