1

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.

cabrerahector
  • 3,653
  • 4
  • 16
  • 27
Nikhil
  • 15
  • 1
  • 6

2 Answers2

2

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;
Mateo Randwolf
  • 2,823
  • 1
  • 6
  • 17
Jayr
  • 592
  • 1
  • 3
  • 14
1

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.

nameisnikk
  • 51
  • 3