Google Calendar API 显示错误且响应不佳

编程入门 行业动态 更新时间:2024-10-07 19:27:44

Google Calendar API 显示错误且响应<a href=https://www.elefans.com/category/jswz/34/1737492.html style=不佳"/>

Google Calendar API 显示错误且响应不佳

我正在尝试创建一个向用户发送日历邀请的功能,但它无法正常工作? Google Calendar API 显示错误且响应不佳 代码

const {google} = require('googleapis');
const { GoogleAuth } = require('google-auth-library');


function sendCalendarInvite(email, users, time, subject, description) {
  // Authenticate with the Google Calendar API
  // const auth = new google.auth.GoogleAuth({
    const auth = new google.auth.JWT({
      keyFilename: "new.json",
      scopes: [""],
    });
  const calendar = google.calendar({ version: 'v3', auth });

  // Build the calendar invite event
  const event = {
    summary: subject,
    description: description,
    start: { dateTime: time.start },
    end: { dateTime: time.end },
    attendees: users.map((user) => ({ email: user })),
    reminders: { useDefault: true },
    conferenceDataVersion: 1,
  };`

  console.log(event);
  // Send the calendar invite to the specified email
  const res = calendar.events.insert({
    auth: auth,
    calendarId: 'primary',
    sendUpdates: 'all',
    resource: event,
  }, function(err, event){
    // console.log("Event Created %s", event.data);
    if(err){
      console.log("There was a error in contacting the calender service", + err);
      return;
    }
    console.log("Event Created %s", event.data.htmlLink);
  });

  console.log(`Calendar invite sent to ${email}`);
  console.log(res);
}

日历邀请已发送至####### 不明确的 联系日历服务 NaN

时出错

我很困惑,是代码问题还是API错误。我知道这个问题已经有了答案,但我无法解决我的问题,所以我希望你能帮助我,或者至少建议我尝试什么,因为我不确定该做什么或怎么做调试以解决我的问题。

回答如下:

更多推荐

Google Calendar API 显示错误且响应不佳

本文发布于:2024-05-13 14:56:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1759750.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不佳   错误   Google   Calendar   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!