以下は、同様のプロジェクトで使用したコードの一部です。私は、OAuthを使うよりもはるかに簡単なgoogle apiと.netフレームワークを使用しました。これらのスニペットは、要するに
Imports Google.GData
Imports Google.GData.Client
Imports Google.GData.Calendar
.....Various Property Fields for the class go here.....
Public Sub AddEvent()
Try
Dim theEvent As New EventEntry
Dim theCalendarService As CalendarService = New CalendarService(FProgID)
Dim theTime As New Extensions.When(FEventStartTime, FEventEndTime)
Dim theEntry As AtomEntry
If FAllDay = True Then
theTime.AllDay = True
Else
theTime.AllDay = False
End If
theEvent.Title.Text = FEventTitle
theEvent.Times.Add(theTime)
If Not FDescription = "" Then
theEvent.Content.Content = FDescription
End If
If Not FEventLocation = "" Then
Dim theLocation As New Extensions.Where
theLocation.ValueString = FEventLocation
theEvent.Locations.Add(theLocation)
End If
If Not FAuthor = "" Then
Dim theAuthor As New AtomPerson
theAuthor.Name = FAuthor
theEvent.Authors.Add(theAuthor)
End If
theCalendarService.setUserCredentials(FstrEmail, FstrPassword)
theEntry = theCalendarService.Insert(FURLNoCookie, theEvent)
FStatus = "Event added successfully to Google Calendar"
Catch ex As Exception
FStatus = "Failed: Event was added to Job List, but not Google Calendar"
End Try
End Sub
Visual Basicで私は.NET FrameworkのためにGoogleが提供するカレンダサービスクラスを使用していたされています。 FstrEmailはカレンダーに関連付けられた電子メールアドレスだけで、FstrPasswordは通常のGoogleパスワードです。 FURLNoCookieは、実際にカレンダーがどこに行くかを指定する場所です。これはカレンダーのXMLプライベート共有URLです(カレンダーの設定>プライベートアドレスから取得)。あなたが最初のカレンダーからこのURLを取得すると、それは更新とエントリを削除するために使用することができ、この
http://www.google.com/calendar/feeds/somebody%40gmail.com/private/full
同様のプロセスのように見えるためにそれを修正し、この
http://www.google.com/calendar/feeds/somebody%40gmail.com/private-188ba1932aa23d4a64ag712db232bfe8b/basic
ようになります。私は複数のGoogleカレンダーとスプレッドシートを同期するためにこれを使用し、それは正常に動作します。
ええ、それについても考えていましたが、1日でリクエストが多すぎるため、潜在的な閉塞に陥ることになります。 1日に10〜15kのさまざまなイベントを簡単に同期できます。あなたはこれに悩まされましたか? – wilbbe01
私はこれに何ら問題はなかった。しかし、私はその負荷の高さの下で決して負荷試験を受けたことはありません。私がやっていることは一日に100回ほどです。 – ThinkerIV