Google Calendar API不适用于私人日历

时间:2019-02-26 19:52:04

标签: php google-calendar-api google-api-php-client

我的Google Calendar API使用以下代码可以很好地工作:

private $client;


    public function __construct() {


        $this->client = new Google_Client();
        $this->client->setAuthConfig(__DIR__ . '/client_id.json');
        $this->client->setScopes("https://www.googleapis.com/auth/calendar.events.readonly");
        $calendarService = new Google_Service_Calendar($this->client);

    }


public function showCalendar() {
    $calendarService = new Google_Service_Calendar($this->client);
    $myCalendarID = "en.usa#holiday@group.v.calendar.google.com";
    $events = $calendarService->events->listEvents($myCalendarID, array(
                                'timeMin' => date(DATE_RFC3339), 
                                'maxResults' => 4))->getItems();


    foreach ($events as $e) {
        $this->eventsToReturn .= "<div class='summary'>";
        $this->eventsToReturn .= $e->getSummary();
        $this->eventsToReturn .= ' <span>(';
        $this->eventsToReturn .= $e->start->date;
        $this->eventsToReturn .= ' )<span>';
        $this->eventsToReturn .= "</div>";


    }
    return $this->eventsToReturn;

上面的代码正在使用公共日历。我将$ myCalendarID更改为引用私有日历后,就会得到

Uncaught Google_Service_Exception: { "error": { "errors": [ { "domain": "global", "reason": "notFound", "message": "Not Found" } ], "code": 404, "message": "Not Found" } }

我是否需要使用我的私人日历进行验证?

0 个答案:

没有答案
相关问题