How to use the google calendar API's functions
===

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 wich is not instanciated by a New().