使用php中的api从google日历获取数据
我正在使用谷歌api php客户端库从日历中获取数据,它显示了错误 PHP致命错误:未捕获的Google\u服务\u异常:调用GET时出错 这是我的代码:使用php中的api从google日历获取数据,php,api,calendar,google-calendar-api,Php,Api,Calendar,Google Calendar Api,我正在使用谷歌api php客户端库从日历中获取数据,它显示了错误 PHP致命错误:未捕获的Google\u服务\u异常:调用GET时出错 这是我的代码: <?php include(__DIR__.'/google-api-php-client-master/src/Google/autoload.php'); $client = new Google_Client(); $client->setApplicationName("Google Calendar"); $cli
<?php
include(__DIR__.'/google-api-php-client-master/src/Google/autoload.php');
$client = new Google_Client();
$client->setApplicationName("Google Calendar");
$client->setDeveloperKey('Zs4-y4qSHh8pDDtq7bnY5bdw');
$cal = new Google_Service_Calendar($client);
$calendarId = 'primary';
$events = $cal->events->listEvents($calendarId);
$calTimeZone = $events->timeZone;
date_default_timezone_set($calTimeZone);
foreach ($events->getItems() as $event) {
$eventDateStr = $event->start->dateTime;
if(empty($eventDateStr))
{
$eventDateStr = $event->start->date;
}
$temp_timezone = $event->start->timeZone;
if (!empty($temp_timezone)) {
$timezone = new DateTimeZone($temp_timezone);
} else { $timezone = new DateTimeZone($calTimeZone);
}
$eventdate = new DateTime($eventDateStr,$timezone);
$link = $event->htmlLink;
$TZlink = $link . "&ctz=" . $calTimeZone;
$newmonth = $eventdate->format("M");
$newday = $eventdate->format("j");
?>
<div class="event-container">
<div class="eventDate">
<span class="month"><?php
echo $newmonth;
?></span><br />
<span class="day"><?php
echo $newday;
?></span><span class="dayTrail"></span>
</div>
<div class="eventBody">
<a href="<?php echo $TZlink; ?>">
<?php echo $event->summary;
?>
</a>
</div>
</div>
提前感谢:)这是刚开始发生的吗?这可能是因为GoogleCalendar正在经历一次非常广泛的(全球范围的?)服务器宕机。现在它正在工作,我的图书馆出现了一些问题。这是不是刚刚开始发生的?这可能是因为GoogleCalendar正在遭受一个非常广泛的(全球范围的?)服务器中断。现在它正在工作,我的库出现了一些问题