gpt4 book ai didi

c# - 带有谷歌日历的通用 Windows 平台应用程序

转载 作者:太空宇宙 更新时间:2023-11-03 12:37:06 24 4
gpt4 key购买 nike

嘿,我正在尝试制作一个通用 Windows 平台应用程序,其中包含谷歌日历,但我无法弄清楚如何转换代码,我得到了可以在 WPF 应用程序上运行的代码。我不是最擅长编码的 https://developers.google.com/google-apps/calendar/quickstart/dotnet这是我一开始用作指南的网站,如果它有任何帮助,有帮助吗?代码如下:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Calendar.v3;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Services;
using Google.Apis.Util.Store;

namespace Test1UWA
{
class GoogleEvents4
{
public string Title { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
}

class GoogleClass4
{
public List<GoogleEvents4> GoogleEvents = new List<GoogleEvents4>();

static string[] Scopes = { CalendarService.Scope.CalendarReadonly };
static string ApplicationName = "Google Calendar API .NET Quickstart";



public GoogleClass4()
{
UserCredential credential;

using (var stream =
new FileStream("client_secret4.json", FileMode.Open, FileAccess.Read))
{
string credPath = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath, ".credentials/calendar-dotnet-quickstart.json");

credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;

}
// Create Google Calendar API service.
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});

// Define parameters of request.
EventsResource.ListRequest request = service.Events.List("primary");
request.TimeMin = DateTime.Now;
request.ShowDeleted = true;
request.SingleEvents = true;
request.MaxResults = 10;
request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;

// List events.
Events events = request.Execute();
if (events.Items != null && events.Items.Count > 0)
{
foreach (var eventItem in events.Items)
{
string when = eventItem.Start.DateTime.ToString();
if (String.IsNullOrEmpty(when))
{
when = eventItem.Start.Date;
}

GoogleEvents.Add(new GoogleEvents4 { Title = eventItem.Summary, StartDate = eventItem.Start.DateTime, EndDate = eventItem.End.DateTime });


}
}
}
}
}

最佳答案

目前 Google .net 客户端库不支持 UWP。

来自 client library (supported platform list) 的链接

chrisdunelm 27 days ago Google member Unfortunately we don't support UWP yet, so it can't be on the list yet. Maybe we should highlight that we don't support it :(

更新:

We plan to support UWP in the v2.0 release, which we hope will be early 2017.

关于c# - 带有谷歌日历的通用 Windows 平台应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40522651/

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