def main():
"""Shows basic usage of the Google Calendar API.
Creates a Google Calendar API service object and outputs a list of the next
10 events on the user's calendar.
"""
rValue = ""
credentials = get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('calendar', 'v3', http=http)
now = datetime.datetime.utcnow().isoformat() + 'Z' # 'Z' indicates UTC time
rValue = rValue + 'Getting the upcoming 10 events\n'
eventsResult = service.events().list(
calendarId='primary', timeMin=now, maxResults=10, singleEvents=True,
orderBy='startTime').execute()
events = eventsResult.get('items', [])
if not events:
rValue = rValue + 'No upcoming events found.\n'
for event in events:
start = event['start'].get('dateTime', event['start'].get('date'))
rValue = rValue + start + " " + event['summary'] + '\n'
return rValue
评论列表
文章目录