phpgoogle-calendar-apigoogle-api-php-client

Google Calendar API: Requesting only existing events


I'm hoping someone can pint me in the right direction. I am succesfully pulling events, calendars, multiple calendars, etc, uding the Google Calendar API. However, the results are showing each and every day of any month regardless if there is an actual event or not.

What field do I need to verify to weed out the "non events days" or what query do I need to filter the results?

Here is the current PHP array of the query options I'm using:

$optParams = array(
'maxResults' => 100,
'orderBy' => 'startTime',
'singleEvents' => TRUE,
//'timeMin' => date('c'),
'timeMin' => date('c', strtotime('-30 days'))
);

Thanks in advance!

Here is an example of an "empty" event:

Google\Service\Calendar\Event Object
(
    [internal_gapi_mappings:protected] => Array
        (
        )

    [modelData:protected] => Array
        (
        )

    [processed:protected] => Array
        (
        )

    [collection_key:protected] => recurrence
    [anyoneCanAddSelf] => 
    [attachmentsType:protected] => Google\Service\Calendar\EventAttachment
    [attachmentsDataType:protected] => array
    [attendeesType:protected] => Google\Service\Calendar\EventAttendee
    [attendeesDataType:protected] => array
    [attendeesOmitted] => 
    [colorId] => 
    [conferenceDataType:protected] => Google\Service\Calendar\ConferenceData
    [conferenceDataDataType:protected] => 
    [created] => 2022-04-29T17:19:37.000Z
    [creatorType:protected] => Google\Service\Calendar\EventCreator
    [creatorDataType:protected] => 
    [description] => 
    [endType:protected] => Google\Service\Calendar\EventDateTime
    [endDataType:protected] => 
    [endTimeUnspecified] => 
    [etag] => "3412060797546000"
    [eventType] => workingLocation
    [extendedPropertiesType:protected] => Google\Service\Calendar\EventExtendedProperties
    [extendedPropertiesDataType:protected] => 
    [focusTimePropertiesType:protected] => Google\Service\Calendar\EventFocusTimeProperties
    [focusTimePropertiesDataType:protected] => 
    [gadgetType:protected] => Google\Service\Calendar\EventGadget
    [gadgetDataType:protected] => 
    [guestsCanInviteOthers] => 
    [guestsCanModify] => 
    [guestsCanSeeOtherGuests] => 
    [hangoutLink] => 
    [htmlLink] => https://www.google.com/calendar/event?eid=Ym0wdGdvMzNiZnV1MnRiZzc3aDg4OTJyaGNfMjAyNDA5MTYgZ3JlZ2dAYmx1bW9vY3JlYXRpdmUuY29t
    [iCalUID] => bm0tgo33bfuu2tbg77h8892rhc@google.com
    [id] => bm0tgo33bfuu2tbg77h8892rhc_20240916
    [kind] => calendar#event
    [location] => 
    [locked] => 
    [organizerType:protected] => Google\Service\Calendar\EventOrganizer
    [organizerDataType:protected] => 
    [originalStartTimeType:protected] => Google\Service\Calendar\EventDateTime
    [originalStartTimeDataType:protected] => 
    [outOfOfficePropertiesType:protected] => Google\Service\Calendar\EventOutOfOfficeProperties
    [outOfOfficePropertiesDataType:protected] => 
    [privateCopy] => 
    [recurrence] => 
    [recurringEventId] => bm0tgo33bfuu2tbg77h8892rhc
    [remindersType:protected] => Google\Service\Calendar\EventReminders
    [remindersDataType:protected] => 
    [sequence] => 0
    [sourceType:protected] => Google\Service\Calendar\EventSource
    [sourceDataType:protected] => 
    [startType:protected] => Google\Service\Calendar\EventDateTime
    [startDataType:protected] => 
    [status] => confirmed
    [summary] => Office
    [transparency] => transparent
    [updated] => 2024-01-23T17:19:58.773Z
    [visibility] => public
    [workingLocationPropertiesType:protected] => Google\Service\Calendar\EventWorkingLocationProperties
    [workingLocationPropertiesDataType:protected] => 
    [creator] => Google\Service\Calendar\EventCreator Object
        (
            [internal_gapi_mappings:protected] => Array
                (
                )

            [modelData:protected] => Array
                (
                )

            [processed:protected] => Array
                (
                )

            [displayName] => Gregg Moore
            [email] => myemail@myemail.com
            [id] => 
            [self] => 1
        )

    [organizer] => Google\Service\Calendar\EventOrganizer Object
        (
            [internal_gapi_mappings:protected] => Array
                (
                )

            [modelData:protected] => Array
                (
                )

            [processed:protected] => Array
                (
                )

            [displayName] => Gregg Moore
            [email] => myemail@myemail.com
            [id] => 
            [self] => 1
        )

    [start] => Google\Service\Calendar\EventDateTime Object
        (
            [internal_gapi_mappings:protected] => Array
                (
                )

            [modelData:protected] => Array
                (
                )

            [processed:protected] => Array
                (
                )

            [date] => 2024-09-16
            [dateTime] => 
            [timeZone] => 
        )

    [end] => Google\Service\Calendar\EventDateTime Object
        (
            [internal_gapi_mappings:protected] => Array
                (
                )

            [modelData:protected] => Array
                (
                )

            [processed:protected] => Array
                (
                )

            [date] => 2024-09-17
            [dateTime] => 
            [timeZone] => 
        )

    [originalStartTime] => Google\Service\Calendar\EventDateTime Object
        (
            [internal_gapi_mappings:protected] => Array
                (
                )

            [modelData:protected] => Array
                (
                )

            [processed:protected] => Array
                (
                )

            [date] => 2024-09-16
            [dateTime] => 
            [timeZone] => 
        )

    [reminders] => Google\Service\Calendar\EventReminders Object
        (
            [internal_gapi_mappings:protected] => Array
                (
                )

            [modelData:protected] => Array
                (
                )

            [processed:protected] => Array
                (
                )

            [collection_key:protected] => overrides
            [overridesType:protected] => Google\Service\Calendar\EventReminder
            [overridesDataType:protected] => array
            [useDefault] => 
        )

    [workingLocationProperties] => Google\Service\Calendar\EventWorkingLocationProperties Object
        (
            [internal_gapi_mappings:protected] => Array
                (
                )

            [modelData:protected] => Array
                (
                )

            [processed:protected] => Array
                (
                )

            [customLocationType:protected] => Google\Service\Calendar\EventWorkingLocationPropertiesCustomLocation
            [customLocationDataType:protected] => 
            [homeOffice] => 
            [officeLocationType:protected] => Google\Service\Calendar\EventWorkingLocationPropertiesOfficeLocation
            [officeLocationDataType:protected] => 
            [type] => officeLocation
            [officeLocation] => Google\Service\Calendar\EventWorkingLocationPropertiesOfficeLocation Object
                (
                    [internal_gapi_mappings:protected] => Array
                        (
                        )

                    [modelData:protected] => Array
                        (
                        )

                    [processed:protected] => Array
                        (
                        )

                    [buildingId] => 
                    [deskId] => 
                    [floorId] => 
                    [floorSectionId] => 
                    [label] => 
                )

        )

)

Solution

  • SOLVED: Apparently, one particular Calendar was marked with a location tag (Office). Once I removed it, the API is NOW pulling only the active events! Still, that does not make sense to me just yet, but it's working now. Sheeesh!

    Thank you everyone for your thoughts. They do help!