Search code examples
phpgoogle-apigoogle-calendar-apigoogle-api-php-client

How to get the creator of the event?


I want get the creator of a Google Calendar Event, so I browsed the documentation page, specifically this section and I saw that there is an object called creator, but how can I extract this from an event taken by the calendar?

My code looks like this:

foreach ($events->getItems() as $event)
{
    $appointment = [
        'start_datetime' => date('Y-m-d H:i:s', strtotime($event->start->getDateTime())),
        'end_datetime' => date('Y-m-d H:i:s', strtotime($event->end->getDateTime())),
        'notes' => $event->getDescription(),
        'title' => $event->getSummary(),
        'id_user' => $operator_id,
        'id_google_calendar' => $event->getId(),
        'attendee' => []
        'creator' => ??????
    ];
}

Solution

  • Either of these two options should work remember the creator will need to be uppercase first letter.

    $event->Creator()  
    
    $event->getCreator()  
    

    If I recall

    $event->Creator['email'] should also work.
    

    This library is generated programmatic via the Discovery services API. The documentation has not been generated there for a lot of it will not show up in the documentation its an experience thing. When you have worked with the library for a while you get to know how its designed.