I’m trying to use the Google calendar API and I can’t properly call the built-in functions. For reference:
$events = $service->events->listEvents('primary'); while(true) { foreach ($events->getItems() as $event) { echo $event->getSummary(); } $pageToken = $events->getNextPageToken(); if ($pageToken) { $optParams = array('pageToken' => $pageToken); $events = $service->events->listEvents('primary', $optParams); } else { break; } }
This code return a fatal error:
Call to a member function
getItems()
on a non-object
I don’t understand how to use an object which is not instantiated by a New()
.
Advertisement
Answer
You need to add this line into your code
$client->setUseObjects(true);