我有一个脚本(来自GitHub),它使用Google Calendar API显示即将发生的事件。
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="format-google-calendar.js"></script>
<script>
formatGoogleCalendar.init({
calendarUrl: 'https://www.googleapis.com/calendar/v3/calendars/7aqribjvrco83j69ufindoig3g@group.calendar.google.com/events?key=AIzaSyDls1AFdCYUTxYRWpYNUiLwOarKao3WV_c',
past: true,
upcoming: true,
sameDayTimes: true,
pastTopN: 20,
upcomingTopN: 3,
itemsTagName: 'li',
upcomingSelector: '#events-upcoming',
pastSelector: '#events-past',
upcomingHeading: '<h2>Upcoming events</h2>',
pastHeading: '<h2>Past events</h2>',
format: ['*date*', ': ', '*summary*', ' — ', '*description*', ' in ', '*location*']
});
我想要做的是将事件的不同部分存储在每个事件的PHP变量中,例如:
<?php
$date= JSON Date
<--! For next event !-->
$date2= JSON Date2
$date3= JSON Date3
?>
我只需要3,因为它只会显示3个即将举行的活动。
答案 0 :(得分:0)
<?php
$date= file_get_contents('url_for_date');
$dateobj = json_decode($date);
$date2= file_get_contents('url_for_date2');
$date2obj = json_decode($date2);
$date3= file_get_contents('url_for_date3');
$date3obj = json_decode($date3);
?>