"; // count the number of events $event_count = count($obj['data']); function sortFunction($a,$b){ if ($a['start_time'] == $b['start_time']) return 0; return strtotime($a['start_time']) - strtotime($b['start_time']); } usort($obj['data'],"sortFunction"); for($x=0; $x<$event_count; $x++){ // set timezone $timezone=isset($obj['data'][$x]['timezone']) ? $obj['data'][$x]['timezone'] : "America/Los_Angeles"; date_default_timezone_set($timezone); $start_date = date( 'l, F d, Y', strtotime($obj['data'][$x]['start_time'])); // in my case, I had to subtract 9 hours to sync the time set in facebook $start_time = date('g:i a', strtotime($obj['data'][$x]['start_time'])); $pic_big = isset($obj['data'][$x]['cover']['source']) ? $obj['data'][$x]['cover']['source'] : "https://graph.facebook.com/v3.0/{$fb_page_id}/picture?type=large"; $eid = $obj['data'][$x]['id']; $name = $obj['data'][$x]['name']; $description = isset($obj['data'][$x]['description']) ? $obj['data'][$x]['description'] : ""; // place $place_name = isset($obj['data'][$x]['place']['name']) ? $obj['data'][$x]['place']['name'] : ""; $city = isset($obj['data'][$x]['place']['location']['city']) ? $obj['data'][$x]['place']['location']['city'] : ""; $country = isset($obj['data'][$x]['place']['location']['country']) ? $obj['data'][$x]['place']['location']['country'] : ""; $zip = isset($obj['data'][$x]['place']['location']['zip']) ? $obj['data'][$x]['place']['location']['zip'] : ""; $location=""; if($place_name){ $location.="{$place_name}"; } if($city){ $location.= $location ? ", {$city}" : "{$city}"; } if($country){ $location.= $location ? ", {$country}" : "{$country}"; } if($zip){ $location.= $location ? ", {$zip}" : "{$zip}"; } if(empty($location)){ $location="Location not set or event data is too old."; } $complete_event_add="{$location}"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "What:"; echo "{$name}"; echo ""; echo ""; echo "When:"; echo "{$start_date} at {$start_time}"; echo ""; echo ""; echo "Where:"; echo "{$complete_event_add}"; echo ""; echo ""; echo "Description:"; echo "{$description}"; echo ""; echo ""; echo "Facebook Link:"; echo ""; echo "View on Facebook"; echo ""; echo ""; } echo ""; ?>