我正在尝试使用www.fullcalendar.io中的完整日历,它传递了一个返回JSON格式数据的URL:
[
{"id":"29041412","start":"2029-04-14T12:00","end":"2029-04-14T1:00","title":"Victor"},
{"id":"28041411","start":"2028-04-14T11:00","end":"2028-04-14T2030:00","title":"nani"},
{"id":"15051417","start":"2015-05-14T17:00","end":"2015-05-14T2029:00","title":"nani"},
{"id":"29041411","start":"2029-04-14T11:00","end":"2029-04-14T2016:00","title":"papapa"},
{"id":"30041411","start":"2030-04-14T11:00","end":"2030-04-14T2030:00","title":"baiak"},
{"id":"30041417","start":"2030-04-14T17:00","end":"2030-04-14T2031:00","title":"iepwpamxb"},
{"id":"15051412","start":"2015-05-14T12:00","end":"2015-05-14T2031:00","title":"lala"}
]
我试图遵循并编辑完整日历包中的一个演示,但它显示的是json文件,而不是URL。我找不到传递返回此数据的URL和将事件放入日历的完整日历的解决方案。我从网上解释的json中获取json的格式。
这是我的php代码:
// Read and parse our events JSON file into an array of event data arrays.
$json = file_get_contents('http://***/diary_service_natursais.php?method=getEntireBooking');
$input_arrays = json_decode($json, true);
// Accumulate an output array of event data arrays.
$output_arrays = array();
foreach ($input_arrays as $array) {
// Convert the input array into a useful Event object
$event = new Event($array, $timezone);
// If the event is in-bounds, add it to the output
if ($event->isWithinDayRange($range_start, $range_end)) {
$output_arrays[] = $event->toArray();
}
}
首先,您需要定义Event对象。你可以尝试包括这个文件如下:
require './utils.php';
然后需要定义日期格式为yyyy-mm-dd-的$range_start和$range_end变量
您可以查看此示例。