Google Calendar API如何查找与会者列表 [英] Google Calendar API how to find attendee list

查看:61
本文介绍了Google Calendar API如何查找与会者列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用Google Calendar API查找会议的与会者列表.要提取与会者电子邮件,我需要以下代码:

I need to find attendee list for a meeting using Google Calendar API. To extract attendee email, I have below code:

eventsResult = service.events().list(calendarId='primary',timeMin=tmin,timeMax=tmax,singleEvents=True,orderBy='startTime').execute()
    events = eventsResult.get('items', [])

for event in events:
            start = event['start'].get('dateTime', event['start'].get('date'))
            end = event['end'].get('dateTime', event['end'].get('date'))
            attendees = event['attendees'].get('email', event['attendees'].get('email'))
            print(attendees)

但是出现错误

attendees = event['attendees'].get('email', event['attendees'].get('email'))
AttributeError: 'list' object has no attribute 'get'

我想念什么?有什么建议吗?

What am I missing? Any suggestion on how to do it?

推荐答案

如果您正在寻找解决方案,该怎么办? attendees的结构如下.

If you are looking for the solution yet, how about this? The structure of attendees is as follows.

{
  "items": [
    {
      "attendees": [
        {
          "email": "### email ###",
          "displayName": "### name ###",
          "responseStatus": "#####"
        }
      ]
    }
  ]
}

那修改呢?

for event in events:
            start = event['start'].get('dateTime', event['start'].get('date'))
            end = event['end'].get('dateTime', event['end'].get('date'))
            attendees = event['attendees'].get('email', event['attendees'].get('email'))
            print(attendees)

收件人:

for event in events:
    start = event['start'].get('dateTime', event['start'].get('date'))
    end = event['end'].get('dateTime', event['end'].get('date'))
    print("{0}, {1}".format(start, end))
    for attendee in event['attendees']:
        attendees = attendee.get('email', attendee.get('email'))
        print(attendees)

如果我误解了您的问题,而您已经有了解决方案,对不起.

If I misunderstand your question and you already have the solution, I'm sorry.

这篇关于Google Calendar API如何查找与会者列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆