Tag: google api dotnet client

Google PageSpeed API dotnet .net

我已经设置了一个基本的C#应用​​程序来在我使用Google.Apis.Pagespeedonline.v2 nuget包指定的网站上运行PageSpeed测试。 设置很简单,我有一个变量,我可以指定url,然后进入服务 // Create the service. var service = new PagespeedonlineService(new BaseClientService.Initializer { ApplicationName = “PageSpeed Sample”, ApiKey = “[API_KEY_HERE]” }); var url = “URL_TO_TEST”; // Run the request. var result = await service.Pagespeedapi.Runpagespeed(url).ExecuteAsync(); 问题是.Runpagespeed方法只接受URL。 我需要能够至少指定“移动”策略,这样我才能获得桌面和移动设备的分数。 我知道这在其他库中是可行的,但在.NET中似乎缺失了。 有人知道使用.NET库的方法吗? 在参考文档中,它暗示该方法接受其他可选参数,但它不在代码中。

使用服务帐户身份validation访问Google Calendar API

我能够使用.NET快速入门教程访问Google Calendar API,效果很好! 该教程的问题在于它使用Open Authentication or OAuth2 。 我想使用服务帐户身份validation执行相同操作。 ( https://support.google.com/googleapi/answer/6158857?hl=en ) 有人能举例说明如何使用服务帐户密钥文件访问我的日历吗? 我也试过尝试使用带有C#教程的Google Calendar API身份validation,但无法完成它。

如何在C#中使用google sheet API v4添加工作表?

我一直在使用Google表格API,并遵循Google指南 。 然而,除了谷歌的第二页之外,没有任何例子可以添加工作表并写入.NET中的新工作表。 js有很多,但我不知道如何1)添加工作表或2)写入新工作表。 我怎样才能做到这一点? 现在我能够在示例中读出没有任何问题,而且我只找到另一个对v4 C#的引用。 我尝试回到v3,但所有文档强烈建议使用v4。 有没有人能够这样做? 以下是我迄今为止所做的一切: // Create Google Sheets API service. var service = new SheetsService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName, }); // Define request parameters. // Add new Sheet string sheetName = string.Format(“{0} {1}”, DateTime.Now.Month, DateTime.Now.Day); AddSheetRequest addSheetRequest = new AddSheetRequest(); addSheetRequest.Properties.Title = sheetName; // How […]

无法使用Google Calendar API加载System.Threading.Tasks程序集

解决了 ! 非常感谢Sam Leach 以下是我工作的app.config文件的示例: … 我也发现了这个来源 编辑:原始问题在线下。 我正在使用.NET 4.0 Framework,从我的研究中我知道不再需要System.Threading.Tasks程序集(因为它是自动包含的)。 我错了吗? 如果我是对的,我现在非常确定会引发错误,因为google-api-dotnet-client开发人员使用的System.Threading.Tasks版本与Visual Studio 2010使用的版本不同。 当我删除一些行时,我注意到在检查应用程序的行为时。 这些线出来了: gcal = new CalendarService(new BaseClientService.Initializer() { Authenticator = auth, ApplicationName = APP_NAME, }); 所以,我的新问题是: 有没有办法强制在VS2010中使用一个特定版本的参考组件? 感谢您帮助我,我相信它会对很多人有所帮助,因为google-calendar-api-v3的记录很糟糕。 亲切的问候,布鲁诺。 我的问题是我无法通过VisualStudio访问Google API作为服务。 我收到此错误: L’exception System.IO.FileLoadException n’a pas été gérée Message=Impossible de charger le fichier ou l’assembly ‘System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ ou […]

Google API使用身份validation服务帐户上传文件

我正在尝试通过API Google Drive发送文件,但是,我找不到任何有关如何使用身份validation服务帐户执行C#上传文件的文档。 我下载了Daimto库,但是,当我们使用身份validationClientId和ClientSecret时,他使用DriveService类上传。 但是使用身份validation进行帐户服务后,他返回到PlusService类,发现无法以这种方式上传文件。 有人能帮我吗? 最好的祝福 使用validation服务帐户 public PlusService GoogleAuthenticationServiceAccount() { String serviceAccountEmail = “106842951064-6s4s95s9u62760louquqo9gu70ia3ev2@developer.gserviceaccount.com”; //var certificate = new X509Certificate2(@”key.p12″, “notasecret”, X509KeyStorageFlags.Exportable); var certificate = new X509Certificate2(@”key.p12″, “notasecret”, X509KeyStorageFlags.Exportable); ServiceAccountCredential credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(serviceAccountEmail) { Scopes = new[] { PlusService.Scope.PlusMe } }.FromCertificate(certificate)); // Create the service. var service = new PlusService(new BaseClientService.Initializer() […]

YouTube C#API V3,您如何恢复中断的上传?

我无法弄清楚如何在C#YouTube API的V3中恢复中断的上传。 我现有的代码使用V1并且运行正常,但我正在切换到V3。 如果我在不改变任何内容的情况下调用UploadAsync(),它将从头开始。 使用Fiddler,我可以看到这里给出的协议没有被遵循,上传重新开始。 我已尝试按照V1设置流中的位置,但没有可用的ResumeAsync()方法。 Python示例使用NextChunk,但SendNextChunk方法受到保护,在C#中不可用。 在下面的代码中,如果我将它们完成但是上传整个video而不是仅上传其余部分,则UploadVideo()和Resume()都可以正常工作。 如何使用google.apis.youtube.v3恢复中断的上传? 这是我到目前为止尝试过的C#代码。 private ResumableUpload UploadVideo( YouTubeService youTubeService, Video video, Stream stream, UserCredential userCredentials) { var resumableUpload = youTubeService.Videos.Insert(video, “snippet,status,contentDetails”, stream, “video/*”); resumableUpload.OauthToken = userCredentials.Token.AccessToken; resumableUpload.ChunkSize = 256 * 1024; resumableUpload.ProgressChanged += resumableUpload_ProgressChanged; resumableUpload.ResponseReceived += resumableUpload_ResponseReceived; resumableUpload.UploadAsync(); return resumableUpload; } private void Resume(ResumableUpload resumableUpload) { //I tried seeking […]

如何使用Google.Apis.YouTube.v3和C#将video上传到youtube?

我用C#创建了console应用程序。 这将把Video从本地驱动器upload到youtube 。 我使用此链接在google api中创建了新应用。 我还使用nuget安装了所有必需的packages 。 当我运行我的应用程序时,我收到错误“ 访问被拒绝 ”我无法找到问题。 我在Task Run()方法中遇到错误。 using System; using System.IO; using System.Reflection; using System.Threading; using System.Threading.Tasks; using Google.Apis.Auth.OAuth2; using Google.Apis.Services; using Google.Apis.Upload; using Google.Apis.Util.Store; using Google.Apis.YouTube.v3; using Google.Apis.YouTube.v3.Data; namespace Google.Apis.YouTube.Samples { /// /// YouTube Data API v3 sample: create a playlist. /// Relies on the Google APIs Client Library […]

如果我已经拥有Access Token的值,如何创建UserCredential的实例?

所以我有这个代码 我的问题是如果我已经通过OAuthvalidation了如何配置UserCredential ? 当前场景是代码将显示另一个重定向到谷歌的登录页面。 由于我已经使用asp.net MVC通过OAuth进行了身份validation,并且我已经拥有令牌如何摆脱GoogleWebAuthorizationBroker并直接传递令牌? string[] scopes = new string[] {PlusService.Scope.PlusLogin, PlusService.Scope.UserinfoEmail, PlusService.Scope.UserinfoProfile}; UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = “xxx.apps.googleusercontent.com”, ClientSecret = “xxxx” }, scopes, Environment.UserName, CancellationToken.None, new FileDataStore(“Store”)).Result; PlusService service = new PlusService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = “ArcaneChatV2”, }); PeopleResource.ListRequest listPeople = service.People.List(“me”, PeopleResource.ListRequest.CollectionEnum.Visible); listPeople.MaxResults = 10; PeopleFeed […]

适用于.NET的Analytics Reporting API V4客户端库

我正在尝试从我们的Google分析实例中获取一些数据,并且我想使用适用于.NET的Analytics Reporting API V4客户端库( https://developers.google.com/api-client-library/dotnet/apis / analyticsreporting / v4 )这样我就可以将一些数据烘焙到我们构建的管理站点中。 我无法找到使用此代码的任何示例,文档似乎非常稀疏。 我想使用服务帐户进行授权,因为我们只需要查看与我们控制的分析帐户相关联的数据。 如果有人可以提供一些示例代码或指出我正确的方向使用.net api获取一些基本的报告数据,我将不胜感激