[英]Facebook PHP SDK Birthday APP using FQL and HTML
我使用FQL查询来获取用户朋友的生日。 但是我想按月和日对用户进行排序,这样当我使用JS显示/隐藏月份时,给定月份中的所有生日必须在div中,该div的ID是月份名称中的前3个字母。 这可以实现吗?
到目前为止的代码
$query = "SELECT uid, first_name, last_name, birthday_date, sex, pic_square, current_location, hometown_location FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND strlen(birthday_date) != 0 ORDER BY birthday_date";
$prm = array(
'method' => 'fql.query',
'query' => $query,
'callback' => ''
);
$friends = $facebook->api($prm);
$sort = array();
foreach($friends as $friend){
// note the extra 0's here, to give us padding to filter out duplicate array keys
// this gives us an int in the format 030100, 093100, etc
$key = (int)date('Md00', strtotime($friend['birthday_date']));
// make sure we don't have duplicates...if the key already exists, incrememnt it by one
while(isset($sort[$key])) $key++;
$sort[$key] = $friend;
}
// sort the items by array key
ksort($sort);
我想我明白你想要什么。 为什么不创建一个月数组来构建div,然后在该div内显示该月生日的用户...
<?
$months = array('jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec');
foreach($months as &$month){
?>
<div id="<?=$month?>">
<? // loop through users with birthday in $month ?>
</div>
<?
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.