2014-11-25 127 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