【问题标题】:Find Attendees of an Event查找活动的参与者
【发布时间】:2022-01-07 11:46:22
【问题描述】:

我正在尝试显示“公共”谷歌日历中的事件。我的要求是获取参加者的数量(不一定是参加者的姓名)。但是,当我使用日历 API(使用 API 密钥和 CalendarID)获取事件时;该活动缺少here 提到的整个与会者部分。

我的问题:我需要通过身份验证吗?这是否意味着这不能公开,显示此信息的网页需要“查看者”首先向 Google 进行身份验证?

这是我的代码的 sn-p(已编辑)...

$.ajax({
  type: 'GET',
  url: encodeURI('https://www.googleapis.com/calendar/v3/calendars/' + calendarId+ '/events?key=' + myKey),
  dataType: 'json',
  success: function (response) {
    console.log(response);
    //here is where I need to get the number of participants
  },
  error: function (error) {
    console.log(error);
    //tell that an error has occurred
  }

这是输出...

{种类:'calendar#events',etag:'"p324e9j5nqabva0g"',摘要:'EDWC Schedule',描述:'',更新:'2022-01-04T08:09:10.933Z',...} accessRole: '读者' 默认提醒:(0) [] 描述: '' 电子标签:'""' 项目:(2) [{…}, {…}] 0: {kind: 'calendar#event', etag: '""', id: '', status: 'confirmed', htmlLink:…} 1: {kind: 'calendar#event', etag: '""', id: '', status: 'confirmed', htmlLink:…} 会议数据:{} 创建:'' 创建者:{} 描述: '' 结束:{日期时间:'2022-01-08T16:00:00+11:00',时区:'澳大利亚/悉尼'} 电子标签:'' 事件类型:'默认' 环聊链接:'' html链接:'' iCalUID:'' ID: '' 种类:'日历#事件' 地点:“澳大利亚” 组织者:{电子邮件:'',显示名称:'',自我:真} 序列:0 开始:{日期时间:'2022-01-08T13:00:00+11:00',时区:'澳大利亚/悉尼'} 状态:“确认” 概括: '' 更新:'2022-01-04T08:09:10.933Z' [[原型]]:对象 [[原型]]:对象 长度:2 [[原型]]:数组(0) 种类:'日历#事件' nextSyncToken: 'CIjkzLfSl_UCEAAYASCvg6XIAQ==' 概括: '' 时区:'澳大利亚/墨尔本' 更新:'2022-01-04T08:09:10.933Z' [[原型]]:对象

【问题讨论】:

    标签: javascript google-calendar-api


    【解决方案1】:

    您可以通过这种方式使用Google Api Node.js Client 完成此操作:

    Google Calendar Event Attendees                                                                                 Run in Fusebit
    const calendarClient = googleClient.calendar('v3');
    
    // Update the below fields with your desired values
    const calendarId = 'YOUR_CALENDAR_ID';
    const eventId = 'YOUR EVENT_ID';
    
    const response = await calendarClient.events.get({
      calendarId,
      eventId,
    });
    
    const attendees = response.data.attendees;
    

    【讨论】:

      【解决方案2】:
      • 根据您的问题,答案是肯定的。发送到 Google Calendar API 的每个请求都必须包含授权令牌。现在,该授权并不总是需要同意屏幕,它也可以是短暂的访问令牌API密钥(如你的例子)。我建议您阅读有关授权流程的更多信息here
      • 根据您的代码 sn-p 和响应,事件列表位于响应对象的 items 属性内。 Here 您可以找到响应对象的结构,但简而言之,您可以通过循环访问这些项目来访问事件,如下所示:
      for (var event of response['items']){}
      

      【讨论】:

      • 我没有问如何访问这些项目;我正在寻找似乎没有使用 API 密钥选项出现的“与会者”。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多