简体   繁体   中英

How do I get event ID from Google Calendar API?

Hey I'm using an API for first time, and I am confused about how to get event ID from Calendar API. Currently I'm using the sample quickstart.php file, and getting summary from this:

$results = $service->events->listEvents($calendarId, $optParams);
$events = $results->getItems();

if (empty($events)) {
    print "No upcoming events found.\n";
} else {
    print "Upcoming events:\n";
    foreach ($events as $event) {
        $start = $event->start->dateTime;
        if (empty($start)) {
            $start = $event->start->date;
        }
        printf("%s (%s)\n", $event->getSummary(), $start);
    }
}

Thanks in advance.

It's written in the CalendarList Resource representation of the documentation. id is part of the calendarList Resource object within the array of items . Within the foreach of $events

$event->id;

This is so simple as mention above you can fetch id by $event->ID or you can use

print_r($events) to see the data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM