testCalendar.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:events-organizer 作者: ccanonguy 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号