我的应用程序使用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' '呼叫POST时出错 https://www.googleapis.com/calendar/v3/calendars/myemail@gmail.com/events?key=AIzaSyBddYIgnZJrXHuT8gvX-0tEypxsycw99rA: (400)错误请求'in C:\ xampp \ htdocs \ uis \ google-api-php-client \ src \ io \ apiREST.php:86 Stack 追踪:#0 C:\ XAMPP \ htdocs中\ UIS \谷歌-API-PHP-客户\ SRC \ IO \ apiREST.php(56): apiREST :: decodeHttpResponse(Object(apiHttpRequest))#1 C:\ XAMPP \ htdocs中\ UIS \谷歌-API-PHP-客户\ SRC \服务\ apiServiceResource.php(187): apiREST :: execute(Object(apiServiceRequest))#2 C:\ XAMPP \ htdocs中\ UIS \谷歌-API-PHP-客户\ SRC \的contrib \ apiCalendarService.php(493): apiServiceResource-> __ call('insert',Array)#3 C:\ XAMPP \ htdocs中\ UIS \ Google处理API-PHP-客户\例子\日历\ cal.php(44): EventsServiceResource-> insert('paine1591 @ gmail ...',Object(Event))#4 抛出了{main} C:\ xampp \ htdocs \ uis \ google-api-php-client \ src \ io \ apiREST.php在线 86
myemail@gmail.com是我日历的ID。它适用于其他一切。
我做错了什么?
答案 0 :(得分:1)
您似乎没有设置活动的与会者。
示例:
$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;