* events: [ * { * * }, * ... * ] * } * * If there is a problem the error code will be 400 with a json response of the form: * { * "error": { * "message": "Error message" * } * } */ if (isset($_GET['startdate']) && ($parseddate = strtotime($_GET['startdate']))) { $startdate = $parseddate; } else { $startdate = time(); } if (isset($_GET['enddate']) && ($parseddate = strtotime($_GET['enddate']))) { $enddate = $parseddate; } else { $enddate = time(); } $json = array('events' => array()); foreach (EventTime::getRangeVisible($startdate, $enddate) as $eventTime) { $json['events'][] = $eventTime->toEventSummaryArray(); } fJSON::output($json);
* JSON: * { * * } * * If there is a problem the error code will be 400 with a json response of the form: * { * "error": { * "message": "Error message" * } * } */ $response = array(); if (isset($_GET['id'])) { $event_id = $_GET['id']; try { // get event by id $event = new Event($event_id); $secret_valid = isset($_GET['secret']) && $event->secretValid($_GET['secret']); if ($secret_valid) { $event->unhide(); } $response = $event->toDetailArray($secret_valid); } catch (fExpectedException $e) { $response['error'] = array('message' => $e->getMessage()); } } else { $response['error'] = array('message' => "Request incomplete, please pass an id in the url"); } fJSON::output($response);