我正在开发一个应用程序,该应用程序允许我的用户使用我的 Google 日历之一安排/重新安排日历事件,我不需要用户向 Google 进行身份验证。我需要使用的是带有服务帐户的 Google Calendar API。我试图用 api v2 写一些东西,但我遇到了问题,所以我想知道你是否可以指导我阅读教程或示例,或者只是插入的示例<?phprequire_once './google-api-php-client-2.2.2/vendor/autoload.php';session_start();/************************************************ */$client_id = '751416246659ae431430560098c25ba433c3e483';$Email_address = ' testecalendar@spartan-grail-241202.iam.gserviceaccount.com';$key_file_location = './credentials.json';$client = new Google_Client();$client->setApplicationName("Client_Library_Examples");$key = file_get_contents($key_file_location);// separate additional scopes with a comma $scopes = "https://www.googleapis.com/auth/calendar.readonly";$client->setAuthConfig('./credentials.json');$service = new Google_Service_Calendar($client);?><html><body> <?php $calendarList = $service->calendarList->listCalendarList(); while (true) { foreach ($calendarList->getItems() as $calendarListEntry) { echo $calendarListEntry->getSummary() . "<br>\n"; // get events $events = $service->events->listEvents($calendarListEntry->id); foreach ($events->getItems() as $event) { echo "-----" . $event->getSummary() . "<br>"; } } $pageToken = $calendarList->getNextPageToken(); if ($pageToken) { $optParams = array('pageToken' => $pageToken); $calendarList = $service->calendarList->listCalendarList($optParams); } else { break; } } ?>
- 2 回答
- 0 关注
- 136 浏览
添加回答
举报
0/150
提交
取消