2016-02-26 120 views
0

我試圖修補與新的開始,並使用谷歌API瀏覽器從「日期」爲「日期時間」

所以我此刻的事件看起來像這樣

結束日期現有的事件更改活動的開始日期
{ 
"kind": "calendar#event", 
"etag": "\"2912997881756000\"", 
"id": "3fpkrr85sdfdgsdfsdsdflgn7vk74qhiv2o", 
"status": "confirmed", 
"htmlLink": "https://www.google.com/calendar/event?eid=M2Zwa3JsdfsdfyODVudWZobGduN3ZrNzRxaGl2Mm8gZHlsbsdfsdfi5pb19xNjUwcWRhcnYyam9vYWYzcTdudmhpc2ZvNEBn", 
"created": "2016-02-26T14:32:33.000Z", 
"updated": "2016-02-26T15:02:20.878Z", 
"summary": "aaaa", 
"creator": { 
    "email": "[email protected]", 
    "displayName": "name" 
}, 
"organizer": { 
    "email": "[email protected]", 
    "displayName": "Display", 
    "self": true 
}, 
"start": { 
    "date": "2016-02-26" 
}, 
"end": { 
    "date": "2016-03-02" 
}, 
"iCalUID": "[email protected]", 
"sequence": 2, 

"reminders": { 
    "useDefault": true 
} 
} 

而且我從谷歌API瀏覽器發出請求是這樣的

PATCH https://www.googleapis.com/calendar/v3/calendars/ddfdfdfdfdf%40group.calendar.google.com/events/3fpkrr85nufhlgn7sdfsafdfdsghgffdhvk74qhiv2o?fields=start&key={YOUR_API_KEY} 

{ 
"start": { 
    "dateTime": "2016-02-16T12:00:00+01:00" 
}, 
"end": { 
    "dateTime": "2016-02-18T13:00:00+01:00" 
} 
} 

但我一直得到以下錯誤

{ 
"error": { 
    "errors": [ 
    { 
    "domain": "global", 
    "reason": "invalid", 
    "message": "Invalid start time." 
    } 
    ], 
    "code": 400, 
    "message": "Invalid start time." 
} 
} 

我猜這是因爲發生的事件是All Day事件,這意味着startDate領域,我送DateTime但是這正是我想做的事情。我不能只是簡單地將startend的類型從Date更改爲DateTime

UPDATE

下面是路徑請求

$client = $this->container->get('google.calendar.client'); 
       $client->setAccessToken($this->auth()->getIdentity()->getGoogleAccessToken()); 
       $service = new \Google_Service_Calendar($client); 
       $event = new \Google_Service_Calendar_Event($eventData); 
       $event = $service->events->patch($this->auth()->getIdentity()->getGoogleCalendarId(), $item->getGoogleId(), $event); 
       $item->setGoogleId($event->getId()); 
       $this->getItemRepo()->save($item); 

回答

3

PHP代碼似乎是用剩的日期的問題。明確設置日期爲空作品:

{ 
"start": { 
    "dateTime": "2016-02-16T12:00:00+01:00", 
    "date": null 
}, 
"end": { 
    "dateTime": "2016-02-18T13:00:00+01:00", 
    "date": null 
} 
} 
+0

感謝您的答覆。它似乎是從API瀏覽器工作,但我仍然通過PHP SDK獲取相同的錯誤。 (我發送的數據的屏幕截圖在這裏http://grab.by/Oro2) – Optimus

+0

您是否也在使用補丁?它看起來像截圖中的完整事件。你能嘗試捕捉網絡請求嗎? – luc

+0

請參閱代碼 – Optimus

相關問題