谷歌日历事件 API 抛出错误


Google Calendar Events API throwing error

我使用 OAuth 对我的应用程序进行身份验证 - 我已经使用日历 API 对其进行了测试。一切正常。我还对事件 API 使用了"快速添加"方法,并且工作正常。但是当我尝试使用以下代码插入时

$event = new Event();
$event->setSummary('hello there');
$event->setLocation('America/Los_Angeles');
$start = new EventDateTime();
$start->setDateTime('2012-04-19');
$event->setStart($start);
$createdEvent = $cal->events->insert('myemail@gmail.com', $event);

我收到以下错误:

致命错误:未捕获的异常"apiServiceException",并显示消息 '调用开机自检
时出错 https://www.googleapis.com/calendar/v3/calendars/myemail@gmail.com/events?key=AIzaSyBddYIgnZJrXHuT8gvX-0tEypxsycw99rA: (400) 错误请求' 在 C:''xampp''htdocs''uis''google-api-php-client''src''io''apiREST.php:86 Stack 跟踪:#0 C:''xampp''htdocs''uis''google-api-php-client''src''io''apiREST.php(56): apiREST::d ecodeHttpResponse(Object(apiHttpRequest)) #1 C:''xampp''htdocs''uis''google-api-php-client''src''service''apiServiceResource.php(187): apiREST::execute(Object(apiServiceRequest)) #2 C:''xampp''htdocs''uis''google-api-php-client''src''contrib''apiCalendarService.php(493): apiServiceResource->__call('insert', Array) #3 C:''xampp''htdocs''uis''google-api-php-client''examples''calendar''cal.php(44): EventsServiceResource->insert('paine1591@gmail...', Object(Event)) #4 {主} 扔进去 C:''xampp''htdocs''uis''google-api-php-client''src''io''apiREST.php on line 86

myemail@gmail.com 是我的日历的ID。它适用于其他所有内容。

我做错了什么?

您似乎没有设置活动的参与者。

例:

$end = new EventDateTime();
$end->setDateTime('2011-06-03T10:25:00.000-07:00');
$event->end = $end;
$attendee1 = new EventAttendee();
$attendee1->email = 'attendeeEmail';
$attendees = array($attendee1, ...);
$event->attendees = $attendees;
相关文章: