繁体   English   中英

如何使用 PHP 和服务帐户创建辅助谷歌日历?

[英]How to create secondary google calendars using PHP and service accounts?

我正在尝试为与服务帐户共享的日历创建辅助日历。 我的代码如下:

putenv('GOOGLE_APPLICATION_CREDENTIALS='.__DIR__.'/service_account.json');
define('SCOPES', Google_Service_Calendar::CALENDAR);

    $client = new Google_Client();
    $client->setApplicationName('REdu Calendars');
    $client->useApplicationDefaultCredentials();
    $client->addScope([SCOPES]);
    $client->setAccessType('offline');

    $service = new Google_Service_Calendar($client);

    $calendar = new Google_Service_Calendar_Calendar();
    $calendar->setSummary($userName);
    $calendar->setTimeZone('America/Los_Angeles');
    $createdCalendar = $service->calendars->insert($calendar);

我认为上面的代码在服务帐户中创建了一个辅助日历。 我真正想要的是能够在与服务帐户共享的日历中创建辅助日历 任何帮助是极大的赞赏。

要为与服务帐号共享日历的用户创建辅助日历,您需要模拟日历的所有者

要求:

PHP 样品:

    $client = new Google_Client();
    $client->setSubject('ownerOfCalendar@domain.com');
    $client->setApplicationName('REdu Calendars');
    $client->useApplicationDefaultCredentials();
    $client->addScope([SCOPES]);
    $client->setAccessType('offline');

    $service = new Google_Service_Calendar($client);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM