php - problem getting the friends birthday with facebook api -
here code , supposed retreive birthday of friends corresponding today .
$friends = $facebook->api('me/friends'); $uids = ""; foreach($friends $f) { $uids .= "uid=$f or "; } $query_uids = substr($uids,0,strlen($query_uids)-4); date_default_timezone_set('utc'); $current_date = date("m/d"); echo "<br />searching : $current_date<br />"; $data = $facebook->api(array('method'=>'fql.query','req_perms' => 'friends_birthday','query'=>"select name, uid user ( ($query_uids) , strpos(birthday_date,'$current_date') >= 0 )") ); if(count($data) > 0) { foreach($data $d) { print_r($d); } } else { echo "<br />no birthdays today<br />"; }
in page have script retrive user friends above 1 , working , result shown snippet issearching , white space !!!!
please thanks
when mean getting friends' birthdays corresponding today - i'm assuming want find if of friends birthday today or not.
1) first thing, have today's date:
$today = date('m\/d');
2) second using date, run query select friends birthday today
$data = $facebook->api(array( 'method' =>'fql.query', 'req_perms' => 'friends_birthday', 'query' => "select uid,name,birthday_date user uid in (select uid2 friend uid1=me()) , strpos(birthday_date,$today)>=0 ") );
3) next check size of data set, if it's 0 - there no birthdays today, else loop through dataset , print friends name birthday today.
if(count($data)==0) { echo 'no friends birthdays today'; } else { echo 'friends birthday today'; foreach($data $today_bday) { echo $today_bday['name']; } }
if not looking - let me know.
Comments
Post a Comment