i want to fetch Facebook friend birthdays from current date to next year current day . todate is the date 364 days later to now in m/d. for this purpose first fql is to retrieve data from jan to current date and second one is for fetching data from current date to 31 dec. i want to apply pagination to upcoming birthdays for next 11 month and 29 days.the following queries are working and fetching the data.can anyone tell me the best way to do so. any suggestion will be highly appreciated.
$fromDate = date('m/d');
$past_birthdays = $facebook->api(array(
'method' => 'fql.query',
'query' => "SELECT uid, name, birthday, birthday_date,substr(birthday_date,0,3) FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date<'$toDate' AND birthday_date>='01/01' order by birthday_date",
'access_token' => $accessToken
));
if ($toDate > $fromDate) {
$condition = " AND birthday_date<'$toDate'";
} else {
$condition = "";
}
$upcoming_birthdays = $facebook->api(array(
'method' => 'fql.query',
'query' => "SELECT uid, name, birthday, birthday_date,substr(birthday_date,0,3) FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date>='$fromDate' $condition order by birthday_date",
'access_token' => $accessToken
));
as in your case i checked on facebook api explorer if you provide limit in your query, then its output in not consistent , the best way to solve your problem is load the whole birthday list in array and show it in slots.
$fromDate = date('m/d');
$past_birthdays = "";
$upcoming_birthdays = $facebook->api(array(
'method' => 'fql.query',
'query' => "SELECT uid, name, birthday, birthday_date, substr(birthday_date, 0,3) from user where uid in (select uid2 from friend where uid1=me()) and birthday_date >='$fromDate' order by birthday_date Limit 0,500",
'access_token' => $accessToken
));
$no = count($upcoming_birthdays); //exit;
if ($no < 500) {
$Limit2 = 500 - $no;
$past_birthdays = $facebook->api(array(
'method' => 'fql.query',
'query' => "SELECT uid, name, birthday, birthday_date, substr(birthday_date, 0,3) from user where uid in (select uid2 from friend where uid1=me()) and birthday_date >='01/01' and birthday_date <= '$fromDate' order by birthday_date Limit 0,$Limit2",
'access_token' => $accessToken
));
//echo count($past_birthdays);exit;
$upcoming_birthdays = array_merge($upcoming_birthdays, $past_birthdays);
no need to take todate as you are fetching for whole year.this ccode is to fetch only 500 but run query for whole year.