2012-04-19 97 views
0

我有我的應用程序使用OAuth進行身份驗證 - 我已經用日曆API對它進行了測試。一切正常。我還爲事件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('[email protected]', $event); 

我收到以下錯誤插入:

Fatal error: Uncaught exception 'apiServiceException' with message 'Error calling POST
https://www.googleapis.com/calendar/v3/calendars/[email protected]/events?key=AIzaSyBddYIgnZJrXHuT8gvX-0tEypxsycw99rA : (400) Bad Request' in C:\xampp\htdocs\uis\google-api-php-client\src\io\apiREST.php:86 Stack trace: #0 C:\xampp\htdocs\uis\google-api-php-client\src\io\apiREST.php(56): apiREST::decodeHttpResponse(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('[email protected]', Object(Event)) #4 {main} thrown in C:\xampp\htdocs\uis\google-api-php-client\src\io\apiREST.php on line 86

[email protected]是我的日曆的ID。它適用於其他一切。

我在做什麼錯?

回答

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;