![](/img/trans.png)
[英]Displaying Google Calendar API v3 Events dateTime in Xamarin C#
[英]Google Calendar API v3 multiple events in one request (using C# server api)
我正在嘗試的是使用.Net的Google日歷客戶端庫通過一個請求發送一批日歷事件。 順便說一下,它的文檔非常差,我仍然不知道如何實現它。 我現在所能做的就是:將事件插入CalendarService.Events對象,然后提取它(每個事件一個請求)。 此api是否甚至為批處理請求提供了此類功能,如果這樣做,任何人都可以顯示示例嗎?
希望這對您有幫助
UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { CalendarService.Scope.Calendar },
"user", CancellationToken.None, new FileDataStore("Calendar.Sample.Store"));
}
// Create the service.
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Google Calendar API Sample",
});
// Create a batch request.
var request = new BatchRequest(service);
request.Queue<CalendarList>(service.CalendarList.List(),
(content, error, i, message) =>
{
// Put your callback code here.
});
request.Queue<Event>(service.Events.Insert(
new Event
{
Summary = "Learn how to execute a batch request",
Start = new EventDateTime() { DateTime = new DateTime(2014, 1, 1, 10, 0, 0) },
End = new EventDateTime() { DateTime = new DateTime(2014, 1, 1, 12, 0, 0) }
}, "YOUR_CALENDAR_ID_HERE"),
(content, error, i, message) =>
{
// Put your callback code here.
});
// You can add more Queue calls here.
// Execute the batch request, which includes the 2 requests above.
await request.ExecuteAsync();
摘自: https : //developers.google.com/api-client-library/dotnet/guide/batch
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.