dongwu5801 2015-10-28 02:27
浏览 50
已采纳

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

  • 写回答

1条回答 默认 最新

  • duancai1904 2015-10-28 02:40
    关注

    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);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?