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

dru*_*392 2 php google-calendar-api

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

我可以做什么:

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

我不能做什么:

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

这是到目前为止我用来完成所有事情的完整代码:

putenv('GOOGLE_APPLICATION_CREDENTIALS=credentials.json');

$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->setScopes('https://www.googleapis.com/auth/calendar');
$client->setSubject('example@gmail.com');

$service = new Google_Service_Calendar($client);

$calendarID = 'primary';
$eventID = 'XXXXXXXXX';
$event = new Google_Service_Calendar_Event(array(
    'sendNotifications' => true,
    'attendees' => array(
        array('email' => 'email1@gmail.com)
    )
));

$event = $service->events->patch($calendarID, $eventID, $event);
Run Code Online (Sandbox Code Playgroud)

Dan*_*son 5

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

我刚刚遇到了完全相同的问题。几样东西:

  • sendNotifications已弃用,您应该改用sendUpdates
  • 可选的参数不会发生在事件本身 - 它们会进入请求。所以你最终得到:
$event = $service->events->patch(
    $calendarID, 
    $eventID, 
    $event, 
    ['sendUpdates' => 'all']
);
Run Code Online (Sandbox Code Playgroud)