2

新しい Google Calendar API v3 Python ライブラリの使用に問題があります。ドキュメントは少しまばらなようです。特定のカレンダーのイベントを認証して取得できます。ただし、gdata ライブラリで可能だったバッチ更新を実行したいと思います。

# example from gdata
# feed that holds all the batch rquest entries
  request_feed = gdata.calendar.data.CalendarEventFeed()
# add the update entries to the batch feed
  request_feed.AddUpdate(entry=updateEntry1)
  request_feed.AddUpdate(entry=updateEntry2)
# submit the batch request to the server
  response_feed = self.cal_client.ExecuteBatch(request_feed, gdata.calendar.client.DEFAULT_BATCH_URL)

https://developers.google.com/google-apps/calendar/batch#example in html に例があります。しかし、pythonライブラリを使用してそれを行うことはできますか?

4

3 に答える 3

3

一般的な Google API Python ライブラリ バッチの手順については、こちらを参照してください。次のようなものを試してください:

from apiclient.http import BatchHttpRequest

def insert_event(request_id, response, exception):
  if exception is not None:
    # Do something with the exception
     pass
  else:
    # Do something with the response
    pass

service = build('calendar', 'v3')

batch = BatchHttpRequest(callback=insert_event)

batch.add(service.events().quickAdd(calendarId="you@domain.com",
  text="Lunch with Jim on Friday"))
batch.add(service.events().quickAdd(calendarId="you@domain.com",
  text="Dinner with Amy on Saturday"))
batch.add(service.events().quickAdd(calendarId="you@domain.com",
  text="Breakfast with John on Sunday"))
batch.execute(http=http)
于 2014-12-04T13:36:16.827 に答える