I've written a very simple RESTful php server (my first experiment with REST, so feel free to make suggestions) to respond to the fullcalendar events callback. It produces exactly the same string output as the json-events.php file in the fullcalendar json example, but for some reason fullcalendar will not accept my server's output.
I've tried messing with the headers because they're different from the ones produced by json-events.php, but I'm not really sure what's awry there, if anything.
The code for the server is below:
<?php
class Listener{
function __construct() {
$this->getResource();
$this->buildResponse();
}
function getResource(){
$parts = explode('/', $_SERVER["REQUEST_URI"]);
$script_name = end(explode('/', $_SERVER["SCRIPT_NAME"]));
$this->resource = $parts[array_search($script_name, $parts) + 1];
$this->resource_id = $parts[array_search($script_name, $parts) + 2];
}
function buildResponse(){
$method = strtolower($_SERVER["REQUEST_METHOD"]);
$this->response_string = $method . ucwords($this->resource);
}
function getResponse(){
return $this->response_string;
}
}
$listener = new Listener();
$thing = $listener->getResponse();
#$thing();
function getEvents(){
$year = date('Y');
$month = date('m');
echo json_encode(array(
array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-10",
'url' => "http://yahoo.com/"
),
array(
'id' => 222,
'title' => "Event2",
'start' => "$year-$month-20",
'end' => "$year-$month-22",
'url' => "http://yahoo.com/"
)
));
}
?>
Any input, help or suggestions would be greatly appreciated!
Thanks,
David