修改事件时超出了日历API使用限制

我正在尝试通过将参与者添加到活动中来修改日历中的活动。该事件是由其他用户手动创建的,我正在尝试让我的应用对其进行修改。最初,这是一个重复发生的事件,我尝试将其修改为单个事件。我可能在24小时内运行了5次此代码,但是我仍然受到速率的限制。我不确定是否只需要等待更长的时间才能恢复API限制,或者是否由于意外地向Google API发送垃圾邮件而丢失了某些东西,而这限制了我的速度。

// schedule contains data pertaining to a user and a time
type Schedule struct {
    Date      string `json:"date"`
    User      string `json:"user"`
    Confirmed bool   `json:"confirmed"`
    DataType  string `json:"datatype"`
    Key       string `json:"key"`
}

// use this to update the calendar with people designated time
func addUserToCalendar(c *gin.Context) {
    calendarSVC := c.MustGet("calendar").(*calendar.Service)
    b,err := c.GetRawData()
    if err != nil {
        log.Error().Msg("Error from getting request body")
        log.Error().Err(err)
        c.JSON(http.StatusInternalServerError,map[string]string{
            "error": "internal server error",})
        return
    }
    scheduleData := &common.Schedule{}
    err = json.Unmarshal(b,scheduleData)
    if err != nil {
        log.Error().Msg("Error extracting schedule into struct")
        log.Error().Err(err)
        c.JSON(http.StatusInternalServerError,})
        return
    }
    log.Info().Msg(scheduleData.Date)
    t,err := time.Parse("2006-01-02",scheduleData.Date)

    if err != nil {
        c.JSON(http.StatusInternalServerError,map[string]string{
            "error": err.Error(),})
        return
    }
    events,err := calendarSVC.Events.List(os.Getenv("CALENDAR_ID")).TimeMin(t.Format(time.RFC3339)).ShowDeleted(false).MaxResults(1).Do()
    if err != nil {
        c.JSON(http.StatusInternalServerError,})
        return
    }

    if len(events.Items) == 0 {
        c.JSON(http.StatusnoContent,map[string]string{
            "error": "no events found",})
        return
    }
    newAttendee := &calendar.EventAttendee{Email: scheduleData.User}
    events.Items[0].Attendees = append(events.Items[0].Attendees,newAttendee)
    for _,attendee := range events.Items[0].Attendees {
        log.Info().Msg(attendee.Email)
    }

    _,err = calendarSVC.Events.Update(os.Getenv("CALENDAR_ID"),events.Items[0].Id,events.Items[0]).Do()
    if err != nil {
        c.JSON(http.StatusInternalServerError,})
        return
    }
    c.JSON(http.StatusOK,"done")
}
dodo0702 回答:修改事件时超出了日历API使用限制

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3136864.html

大家都在问