Reputation: 91
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()
.
Upvotes: 2
Views: 1739
Reputation: 1752
Add it just before the following line
$service = new apiCalendarService($client);
Since
$service->events->listEvents('primary');
returns an array but you need an object here
Upvotes: 0
Reputation: 91
You need to add this line into your code
$client->setUseObjects(true);
Upvotes: 7