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
事件,這意味着start
是Date
領域,我送DateTime
但是這正是我想做的事情。我不能只是簡單地將start
和end
的類型從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);
感謝您的答覆。它似乎是從API瀏覽器工作,但我仍然通過PHP SDK獲取相同的錯誤。 (我發送的數據的屏幕截圖在這裏http://grab.by/Oro2) – Optimus
您是否也在使用補丁?它看起來像截圖中的完整事件。你能嘗試捕捉網絡請求嗎? – luc
請參閱代碼 – Optimus