Google Calendar API会获取可用的事件颜色,从而导致未定义的方法致命错误

I'm trying to fetch the available event colors for a calendar, and I'm getting this error:

PHP Fatal error: Call to undefined method Google_Service_Calendar_Colors_Resource::getEvent()

From the last line of this code:

  $client = new Google_Client();
  $client->setClientId($configArray['google']['calsync']['client_id']);
  $client->setClientSecret($configArray['google']['calsync']['client_secret']);
  $client->setRedirectUri($configArray['google']['calsync']['redirect_uri']);
  $client->setUseBatch(true);
  $client->setScopes('calendar');
  $client->setAccessToken("ACCESSTOKEN");
  $cal_client = new Google_Service_Calendar($client);

  $colors = $cal_client->colors->get();
  $event_colors = $colors->getEvent();

Why is this happening? What can I do to catch this error? I'm following the example used on: https://developers.google.com/google-apps/calendar/v3/reference/colors/get

I figured out the problem. The following code, which sets the client to batch requests is causing the fatal error. This code:

$client->setUseBatch(true);

Should not be present, or it should be:

$client->setUseBatch(false);