使用JSON解析URL到FullCalendar的问题

时间:2014-09-10 11:57:11

标签: php json fullcalendar

我尝试使用www.fullcalendar.io中的完整日历传递返回JSON格式数据的网址:

[
    {"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();
    }
}

1 个答案:

答案 0 :(得分:0)

首先,您需要定义Event对象。您可以尝试包含this文件,如下所示:

require './utils.php';

然后你需要定义$ range_start和$ range_end变量,日期格式为yyyy-mm-dd

您可以查看this示例。