Google 日历 PHP API 不发送邀请电子邮件

2024-04-13

我已使用 PHP 和服务帐户成功与 Google 日历集成。

我可以做什么:

  • 更新日历事件。
  • 将与会者添加到日历活动。

我不能做什么:

  • 添加新与会者时发送邀请电子邮件。

这是迄今为止我用来完成所有事情的完整代码:

putenv('GOOGLE_APPLICATION_CREDENTIALS=credentials.json');

$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->setScopes('https://www.googleapis.com/auth/calendar');
$client->setSubject('[email protected] /cdn-cgi/l/email-protection');

$service = new Google_Service_Calendar($client);

$calendarID = 'primary';
$eventID = 'XXXXXXXXX';
$event = new Google_Service_Calendar_Event(array(
    'sendNotifications' => true,
    'attendees' => array(
        array('email' => '[email protected] /cdn-cgi/l/email-protection)
    )
));

$event = $service->events->patch($calendarID, $eventID, $event);

聚会迟到了,但由于没有答案......

我刚刚遇到了同样的问题。一些事情:

  • sendNotifications已弃用,您应该使用发送更新 https://developers.google.com/calendar/v3/reference/events/update#sendUpdates反而。
  • 可选参数不会出现在事件本身中 - 它们会出现在请求中。所以你最终会得到:
$event = $service->events->patch(
    $calendarID, 
    $eventID, 
    $event, 
    ['sendUpdates' => 'all']
);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Google 日历 PHP API 不发送邀请电子邮件 的相关文章

随机推荐