0
我使用FQL查詢來獲取用戶朋友的生日。但我想根據月份和日期對用戶進行排序,以便給定月份中的所有生日必須位於其ID爲本月名稱中的前3個字母的div中,因爲我使用JS來顯示/隱藏月份。這是可以實現的嗎?使用FQL和HTML的Facebook PHP SDK生日APP
到目前爲止的代碼..
$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);
您可能需要改進您的問題或至少提供一些Javascript代碼才能看到確切地說你想如何使用它。 – 2011-11-16 23:35:21