gpt4 book ai didi

ruby-on-rails - 使用 Google 服务帐户创建的新日历事件不会向与会者发送邀请电子邮件

转载 作者:行者123 更新时间:2023-12-02 01:44:46 24 4
gpt4 key购买 nike

我正在使用 Google 的服务帐户 在 Google 日历中创建一个新事件,并且我还将 sendNotifications 设置为 true,但是在创建事件之后,邀请电子邮件是不发送给与会者 ??

  # new event to be created
event = {
'summary'=> summary,
'description'=> description,
'start'=> {'dateTime' => datetime },
'end' => {'dateTime' => datetime },
'sendNotifications' => true,
'sequence' => sequence,
'reminders' => {
'useDefault' => false,
'overrides' => [
{'minutes' => 60, 'method' => 'email'}
]
},
'attendees'=> [
{
'email'=> email
}
]
}

# build client
client = Google::APIClient.new application_name: "Test", application_version: "0.0.1"
key = Google::APIClient::KeyUtils.load_from_pkcs12(key_file, key_secret)

client.authorization = Signet::OAuth2::Client.new(
:token_credential_uri => 'https://accounts.google.com/o/oauth2/token',
:audience => 'https://accounts.google.com/o/oauth2/token',
:scope => 'https://www.googleapis.com/auth/calendar',
:issuer => ENV['SERVICE_ACCOUNT_EMAIL'],
:grant_type => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
:access_type => 'offline',
:signing_key => key
)

# fetch access token
client.authorization.fetch_access_token!

# create new event
service = client.discovered_api('calendar', 'v3')
client.execute(:api_method => service.acl.insert,
:parameters => {'calendarId' => 'primary'},
:body => JSON.dump(event),
:headers => {'Content-Type' => 'application/json'})

最佳答案

sendNotifications 是请求的属性,而不是事件的属性。请在此处查看插入文档:https://developers.google.com/google-apps/calendar/v3/reference/events/insert您还可以尝试使用资源管理器来查看请求的具体形式:https://developers.google.com/apis-explorer/#p/calendar/v3/ (不要忘记在右上角进行身份验证)。

关于ruby-on-rails - 使用 Google 服务帐户创建的新日历事件不会向与会者发送邀请电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26354179/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com