Forum Moderators: coopster
$FBpage = file_get_contents('https://graph.facebook.com/demo/events?access_token=17097252363624|vNXbO1MPwpvP56jU625tR2526wU');
$FBdata = json_decode($FBpage);
foreach ($FBdata->data as $events )
{
$x_sdt = explode("T",$events->start_time);
$x_sd = explode("-",$x_sdt[0]);
if($x_sdt[0] > date("Y-m-d"))
{
$StatusID = explode("_", $events->id);
echo '<ul class="shows">';
echo '<li class="date">';
echo $x_sd[2]."/".$x_sd[1]."/".$x_sd[0];
echo '</li>';
echo '<li class="title"><a href="'.get_bloginfo('url').'/shows/#'.$events->id.'">'.maxTruncate($events->name, 62).'</a></li>';
echo '</ul>';
}
}
/**
* Compare function for two FB data objects
* where comparison occurs by date in ASC order
*/
function cmpByDate($a, $b) {
$aUnix = <extract timestamp from $a, convert to Unix ts>
$bUnix = <extra timestamp from $b, convert to Unix ts>
if($aUnix == $bUnix) return 0;
// switch 1 and -1 around if you want descending order
return $aUnix > $bUnix ? 1 : -1;
}
usort(fbevents, "cmpByDate");
function cmpByDate($a, $b)
{
$aUnix = strtotime($events->start_time);
$bUnix = strtotime($events->start_time);
if($aUnix == $bUnix) return 0;
return $aUnix > $bUnix ? 1 : -1;
}