2014-11-25 116 views
1

Sinse Google 17日停止API v2,我的数据库同步到Google日历的应用程序停止工作。Google Calander API v3

现在我想迁移到v3,然而它变成了很多努力和缺乏vb.net代码的例子。但我设法得到了一些,但它不工作,我有一些关于它的问题。

首先,Google网站上的新示例说明了那里使用.JSON文件。我如何将这个添加到项目中?

第二,这是从谷歌vb.net示例代码,但它不工作:

Imports System.IO 
Imports System.Threading 
Imports Google.Apis.Auth.OAuth2 
Imports Google.Apis.Calendar.v3 
Imports Google.Apis.Services 
Imports Google.Apis.Util.Store 


Public Class Form1 
    Private Shared Sub Main(args As String()) 
     Dim credential As UserCredential 
     ' This example uses the client_secrets.json file for authorization. 
     ' This file can be downloaded from the Google Developers Console 
     ' project. 
     Using stream = New FileStream("client_secrets.json", FileMode.Open, FileAccess.Read) 
      credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, New() {CalendarService.Scope.Calendar}, "user", CancellationToken.None, New FileDataStore("Calendar.Auth.Store")).Result 
     End Using 

     ' Create the service. 
     Dim service = New CalendarService(New BaseClientService.Initializer() With {Key.HttpClientInitializer = credential, Key.ApplicationName = "Calendar API Sample" }) 
    End Sub 
End Class  

的编译器说,有两种错误的关键。没有regornized优先和新()不vailig。

我希望有人能帮助我走出这一点,或在vb.net

工作示例V3期待读你的答复

回答

0

你应该看看Calendar Migration Guide。它应该作为迁移到v3的良好参考。它还包含各种语言的示例代码,包括.NET。

至于你的错误,New() {CalendarService.Scope.Calendar}, "user"看起来像一个问题给我。对于谷歌日历的范围是:

https://www.googleapis.com/auth/calendarhttps://www.googleapis.com/auth/calendar.readonly

您可能需要参考文档here。取决于您对应用程序做了什么,您可能还需要其他范围。

+0

感谢您的回复。我阅读了有关迁移的文档以及calander服务,但是,问题是我找不到任何信息如何应用正确的语法。也许我错过了一些东西,但我找不到任何使用正确语法的例子。所以也许有人可以帮我解决这个问题? – Triple 2014-12-02 10:17:33