axios 为什么Google Calendar API包含会议详细信息的请求体,但不创建任何会议链接作为响应?

k0pti3hp  于 2023-04-30  发布在  iOS
关注(0)|答案(1)|浏览(93)

我试图创建一个会议事件,但当我尝试使用下面的代码时,我得到了相应的控制台日志。
我也找到了一些参考资料,但都不起作用。
https://issuetracker.google.com/issues/167260246
Create an event with conference using python and Google Calendar API creates the event but not the conference
我正在使用React Native,我也使用了Google Authentication,它运行得非常完美:

const configureGoogleSingin = async () => {
    GoogleSignin.configure({
      androidClientId:
        'some-id',
      scopes: ['https://www.googleapis.com/auth/calendar'],
    });
  };

  const continueWithGoogle = async () => {
    GoogleSignin.hasPlayServices()
      .then(hasPlayService => {
        if (hasPlayService) {
          GoogleSignin.signIn()
            .then(userInfo => {
              // console.log(userInfo);
              checkAuthenticationOnBE(userInfo.user);
            })
            .catch(e => {
              console.log('ERROR IS: ' + JSON.stringify(e));
            });
        }
      })
      .catch(e => {
        console.log('ERROR IS: ' + JSON.stringify(e));
      });
  };

我的代码是这样的:

const conferenceData = {
      // 'allowedConferenceSolutionTypes': ['hangoutsMeet'],
      'createRequest': {
        'requestId': `meet-${Math.random().toString(36).substring(7)}`,
        'conferenceSolutionKey': {
          'type': 'hangoutsMeet',
        },
      },
    };

    const event = {
      'summary': 'ShopOnLive Meeting',
      'description': "I want to buy something.",
      'start': {
        'dateTime': meetDateTime.toISOString(),
        'timeZone': Intl.DateTimeFormat().resolvedOptions().timeZone // current timeZone
      },
      'end': {
        'dateTime': moment(meetDateTime).add(40, 'minutes').toISOString(),
        'timeZone': Intl.DateTimeFormat().resolvedOptions().timeZone // current timeZone
      },
      'conferenceDataVersion': 1,
      'conferenceData': conferenceData,
      'organizer': {
        'email': 'sumit@shoponline.in',
      },
      "attendees": [
        // {
        //   "email": shop.user.email,
        //   "displayName": "Store Owner",
        //   "organizer": false,
        //   "self": true,
        // },
        // {
        //   "email": userEmail,
        //   "displayName": "Client",
        //   "organizer": false,
        //   "self": true,
        // },
      ],
    }

    console.log(event);

    if(!provider_token){
      showToaster("ERROR: Please Logout and Login again.");
    }

    let eventData = null;
    await googleEventCreaterAPI(JSON.stringify(event), provider_token).then(async res=>{
      console.log(res.data);
      eventData = res.data;
    }).catch(err=>console.log(err));

这里有两个控制台。登录第一个控制台。原木

{
    "summary": "ShopOnLive Meeting",
    "description": "I want to buy something.",
    "start": {
        "dateTime": "2023-04-21T14:33:00.000Z",
        "timeZone": "Asia/Calcutta"
    },
    "end": {
        "dateTime": "2023-04-21T15:13:00.000Z",
        "timeZone": "Asia/Calcutta"
    },
    "conferenceDataVersion": 1,
    "conferenceData": {
        "createRequest": {
            "requestId": "meet-dk8ncv",
            "conferenceSolutionKey": {
                "type": "hangoutsMeet"
            }
        }
    },
    "organizer": {
        "email": "sumit@shoponline.in"
    },
    "attendees": []
}

第二台控制台日志

{
    "kind": "calendar#event",
    "etag": "\"3364017758736000\"",
    "id": "q7blnj6j4b4rjvrfu051ssgen4",
    "status": "confirmed",
    "htmlLink": "https://www.google.com/calendar/event?eid=cTdibG5qNmo0YjRyanZyZnUwNTFzc2dlbjQgc3VtaXRAc2hvcG9ubGl2ZS5pbg",
    "created": "2023-04-20T16:41:19.000Z",
    "updated": "2023-04-20T16:41:19.368Z",
    "summary": "ShopOnLive Meeting",
    "description": "I want to buy something.",
    "creator": {
        "email": "sumit@shoponlive.in",
        "self": true
    },
    "organizer": {
        "email": "sumit@shoponlive.in",
        "self": true
    },
    "start": {
        "dateTime": "2023-04-21T20:03:00+05:30",
        "timeZone": "Asia/Kolkata"
    },
    "end": {
        "dateTime": "2023-04-21T20:43:00+05:30",
        "timeZone": "Asia/Kolkata"
    },
    "iCalUID": "q7blnj6j4b4rjvrfu051ssgen4@google.com",
    "sequence": 0,
    "reminders": {
        "useDefault": true
    },
    "eventType": "default"
}
s4n0splo

s4n0splo1#

为了创建带有Google Meet链接的事件,conferenceDataVersion需要作为参数传递,而不是作为有效负载传递。您还必须确保请求正文具有会议数据属性。

示例编码:

const calendarId = "###";
const event = {
  start: { dateTime: "2021-01-01T00:00:00.000+09:00" },
  end: { dateTime: "2021-01-01T00:30:00.000+09:00" },
  attendees: [{ email: "###" }],
  conferenceData: {
    createRequest: {
      requestId: "sample123",
      conferenceSolutionKey: { type: "hangoutsMeet" },
    },
  },
  summary: "sample event with Meet link",
  description: "sample description",
};
gapi.client.calendar.events
  .insert({
    calendarId: calendarId,
    conferenceDataVersion: 1,
    resource: event,
  })
  .then((res) => console.log(res.result));

参考文献:

相关问题