Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google日历PHP API不发送邀请电子邮件_Php_Google Calendar Api - Fatal编程技术网

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

Google日历PHP API不发送邀请电子邮件,php,google-calendar-api,Php,Google Calendar Api,我已经成功地与谷歌日历集成使用PHP与服务帐户 我能做什么: putenv('GOOGLE_APPLICATION_CREDENTIALS=credentials.json'); $client = new Google_Client(); $client->useApplicationDefaultCredentials(); $client->setScopes('https://www.googleapis.com/auth/calendar'); $client->s

我已经成功地与谷歌日历集成使用PHP与服务帐户

我能做什么:

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);
  • 更新日历事件
  • 将与会者添加到日历事件中
我不能做的事:

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);
  • 添加新与会者时发送邀请电子邮件
以下是我迄今为止用来完成所有工作的全部代码:

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);

晚会迟到了,但因为没有答案

我也有同样的问题。几件事:

  • sendNotifications
    已被弃用,您应该改用
  • 可选参数不会出现在事件本身上,而是出现在请求中。因此,你最终会:

这对我也很管用!谢谢我感到困惑的是,他们在文档中没有提到它:(虽然sendNotifications已被弃用,但它似乎仍然是在附加组件中使用appscript的高级日历服务时唯一有效的方法。有人能对此进行解释吗?有效的解决方案就在这里=