具有Google日历的通用Windows平台应用 [英] Universal Windows Platform App with google calendar

查看:107
本文介绍了具有Google日历的通用Windows平台应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我试图制作一个包含Google日历的通用Windows平台应用程序,但是我不知道如何转换代码,我让代码可以在WPF应用程序上工作. 我不是最擅长编码 https://developers.google.com/google的人-apps/calendar/quickstart/dotnet 这是我在开始时用作指导的网站,如果有帮助,有帮助吗? 下面的代码:

Hey im trying to make an Universal Windows Platform App where google calendar is in it, but i cant figure out how to convert the code, i got the code to work on a WPF App. I am not the best at coding https://developers.google.com/google-apps/calendar/quickstart/dotnet this is the site i use as a guideline in the start if its to any help, any help? Code below:

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.

At this time the Google .net Client library does not support UWP.

客户端库(受支持的平台列表)中的链接

chrisdunelm 27天前Google会员不幸的是我们不支持 UWP还没有,所以它还不能在列表中.也许我们应该强调 我们不支持它:(

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 :(

更新:

我们计划在v2.0版本中支持UWP,我们希望在2017年初发布.

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

这篇关于具有Google日历的通用Windows平台应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆