我正在嘗試通過oauth google獲取登錄用戶的所有日曆。截至目前,我可以獲取主日曆中的所有事件,但我也想顯示用戶的所有公共日曆。獲取登錄用戶的所有日曆列表(Google日曆API)
嘗試了一切,但找不到任何方法來提取日曆。這是我正在開發的Rails 5應用程序上的一個紅寶石。
代碼以獲取事件當月
response = client.execute(api_method: service.events.list,
parameters: { 'calendarId' => 'primary',
'timeMin': Time.now.beginning_of_month.iso8601,
'showDeleted': false,
'singleEvents': true,
'maxResults': 10,
'orderBy': 'startTime'},
headers: { 'Content-Type' => 'application/json' })
我試圖client.calendarList.list但它顯示錯誤「未定義的方法calendarList」
感謝提前的幫助。
就像在這[post](http://stackoverflow.com/questions/28772554/google-calendar-api-cant-list-events-from-secondary-calendar)中,其他日曆有自己的ID。日曆API沒有任何可合併不同日曆的功能。因此,一種解決方案是,使用[CalendarList:list](https://developers.google.com/google-apps/calendar/v3/reference/calendarList/list)返回用戶日曆列表中的條目,然後您可以遍歷他們每個人的事件。 [源](http://stackoverflow.com/questions/35169118/how-to-get-all-events-from-google-calendar-using-google-calendar-api) – KENdi