我試圖獲取Facebook的多個飼料,按時間順序解析和分類多個Facebook的JSON源的關鍵
在JSON提要所有對象顯示他們將有「CREATED_TIME」,所以我想用這個作爲重點解析,也不管什麼按時間順序顯示的所有對象養活他們來自
繼承人我的代碼
$urls = array(
//FEED1
'https://graph.facebook.com/GROUP_ID/posts?fields=message,full_picture,description,link,picture,source,name,type,status_type,caption,created_time,permalink_url&limit=10&access_token=ACCESS_TOKEN',
//FEED 2
'https://graph.facebook.com/PAGE_ID/posts?fields=message,full_picture,description,link,picture,source,name,type,status_type,caption,created_time,permalink_url&limit=10&access_token=ACCESS_TOKEN',
//FEED 3
'https://graph.facebook.com/GROUP_ID/posts?fields=message,full_picture,description,link,picture,source,name,type,status_type,caption,created_time,permalink_url&limit=10&access_token=ACCESS_TOKEN');
$results = array();
然後我做
foreach($urls as $index => $url){
$DataContent = file_get_contents($url);
$infoData = json_decode($DataContent, true);
foreach ($infoData['data'] as $Data){
$FBPostCreatedTime = $Data['created_time'];
/*PARSE THE DATA HERE*/
}
}
個
這段代碼的輸出結果每個養活一個接一個,
我怎麼使用$ FBPostCreatedTime合併所有的飼料數據,並按照時間順序顯示呢?
感謝
全部合併進到一個數組,然後對它進行排序 – WizKid