如何在Google日历中创建活动,而不将其保存在垃圾箱中?

问题描述 投票:0回答:1

如何在Google日历中创建活动,而不将其保存在垃圾箱中?我正在研究Google Calendar API(https://developers.google.com/calendar/v3/reference/events/insert)如何在日历上创建事件,插入工作正常,API返回状态为“已确认”。但是在日历中,该事件没有出现。我查看了Google Calendar API,状态为“已取消”,因此我的活动显示在回收站中。我不确定发生了什么,有人知道如何在Google日历上创建一个不会浪费掉的事件?

enter image description here

<?php
class Calendar
{
    private $calendarId         = 'primary';
    private $service            = null;
    private $client             = null;

    public function __construct()
    {
        $this->client = new Client([
            'scopes' => [
                Google_Service_Calendar::CALENDAR,
                Google_Service_Calendar::CALENDAR_READONLY,
                Google_Service_Calendar::CALENDAR_EVENTS,
                Google_Service_Calendar::CALENDAR_EVENTS_READONLY,
            ]
        ]);
        $this->service = new Google_Service_Calendar($this->client->getClient());
    }

    public function eventAdd()
    {
        $email = '[email protected]';

        $event = new Google_Service_Calendar_Event();
        $event->setSummary('Vamos ver agora ;)');
        $event->setStatus('confirmed');
        $start_datetime = new Google_Service_Calendar_EventDateTime();
        $start_datetime->setDateTime('2019-10-10T15:00:00.000-03:00');
        $start_datetime->setTimeZone('America/Sao_Paulo');
        $event->setStart($start_datetime);
        $end_datetime = new Google_Service_Calendar_EventDateTime();
        $end_datetime->setDateTime('2019-10-10T20:00:00.000-03:00');
        $end_datetime->setTimeZone('America/Sao_Paulo');
        $event->setEnd($end_datetime);
        $reminder = new Google_Service_Calendar_EventReminder();
        $reminder->setMethod('popup');
        $reminder->setMinutes(10);
        $reminders = new Google_Service_Calendar_EventReminders();
        $reminders->setUseDefault(false);
        $reminders->setOverrides(array($reminder));
        $event->setReminders($reminders);

        $attendee1 = new Google_Service_Calendar_EventAttendee();
        $attendee1->setEmail($email);
        $attendee1->setResponseStatus('accepted');
        $attendees = array($attendee1);
        $event->attendees = $attendees;
        $optParams = array('sendNotifications' => true, 'maxAttendees' => 1);
        $event = $this->service->events->insert($this->calendarId, $event, $optParams);

        var_dump($event);
    }
}
php laravel google-api composer-php google-calendar-api
1个回答
-2
投票

您是什么意思垃圾?你这附近唯一一个丢垃圾的人。

© www.soinside.com 2019 - 2024. All rights reserved.