ADC で Calender API 叩けるんだっけ
叩ける
して
code:calendar.go
package main
import (
"context"
"fmt"
"log"
"time"
calendar "google.golang.org/api/calendar/v3"
"google.golang.org/api/option"
)
var projectID = "pokutuna-playground"
func main() {
ctx := context.Background()
client, err := calendar.NewService(ctx, option.WithQuotaProject(projectID))
if err != nil {
log.Fatalf("Unable to retrieve Sheets client: %v", err)
}
t := time.Now().Format(time.RFC3339)
events, err := client.Events.List("primary").ShowDeleted(false).SingleEvents(true).TimeMin(t).MaxResults(10).OrderBy("startTime").Do()
if err != nil {
log.Fatalf("%+v", err)
}
for _, item := range events.Items {
fmt.Printf("%s: %s ~ %s\n", item.Summary, item.Start.DateTime, item.End.DateTime)
}
}
イベントみれた
書き込みしようとするとブロックされる?
だと
https://gyazo.com/7399dfd5287b6d5827f8938646158e05
なぜ~~~
ならいける
code:clendar_event_create.go
package main
import (
"context"
"fmt"
"log"
calendar "google.golang.org/api/calendar/v3"
"google.golang.org/api/option"
)
var projectID = "pokutuna-playground"
func main() {
ctx := context.Background()
client, err := calendar.NewService(ctx, option.WithQuotaProject(projectID))
if err != nil {
log.Fatalf("Unable to retrieve Sheets client: %v", err)
}
event := &calendar.Event{
Summary: "oneetyan",
Start: &calendar.EventDateTime{
DateTime: 2022-06-03T14:30:00+09:00,
TimeZone: "Asia/Tokyo",
},
End: &calendar.EventDateTime{
DateTime: 2022-06-03T14:45:00+09:00,
TimeZone: "Asia/Tokyo",
},
}
res, err := client.Events.Insert("primary", event).Do()
if err != nil {
log.Fatalf("%+v", err)
}
fmt.Printf("%+v\n", res)
}