【发布时间】:2013-11-07 23:21:13
【问题描述】:
我已经尝试了几个小时,但我无法让它工作。我使用以下代码(VB)
Private Async Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim credential As UserCredential = Await GoogleWebAuthorizationBroker.AuthorizeAsync(New ClientSecrets With {.ClientId = "my key", .ClientSecret = "my secret"}, New String() {BooksService.Scope.Books}, "user", CancellationToken.None, New FileDataStore("Books.ListMyLibrary"))
Dim service As New BooksService(New BaseClientService.Initializer With {.HttpClientInitializer = credential, .ApplicationName = "LibraryX"})
'Dim bookselve As Bookshelves = Await service.Mylibrary.Bookshelves.List.ExecuteAsync
Dim mm = service.Volumes.Get("9780330441230")
End Sub
它没有给我关于这本书的信息(骆驼俱乐部,大卫巴尔达奇)
有人可以帮帮我吗?
您好, 史蒂文
20131106
我做了一些改变:
Private Async Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim credential As UserCredential = Await GoogleWebAuthorizationBroker.AuthorizeAsync(New ClientSecrets With {.ClientId = "my key", .ClientSecret = "my secret"},
New String() {BooksService.Scope.Books}, "user", CancellationToken.None, New FileDataStore("Books.ListMyLibrary"))
Dim service As New BooksService(New BaseClientService.Initializer With {.HttpClientInitializer = credential, .ApplicationName = "LibraryX"})
'Dim bookselve As Bookshelves = Await service.Mylibrary.Bookshelves.List.ExecuteAsync
Try
rslt = Await service.Volumes.Get("9780330441230").ExecuteAsync
Dim y As Integer = 0
Catch gaex As Google.GoogleApiException
ErrorMessageTextBox.Text = gaex.Message
Catch ex As AggregateException
ErrorMessageTextBox.Text = ex.Message
End Try
End Sub
但是请求的结果是:
enter code hereGoogle.Apis.Requests.RequestError
找不到卷 ID。 [404]
错误 [
消息[找不到卷 ID。]位置[-]原因[未找到]域[全局]
]
知道 VolumeId 必须是什么才能从 Google 获取图书信息吗?
【问题讨论】:
-
API 正在寻找客户端密钥和密钥。您是从上面的示例中删除了这些,还是在尝试代码时没有包括它们?
-
你有异常吗? mm的内容是什么?
-
是的,我故意在这篇文章中留下了密钥和秘密消息。
-
?mm {Google.Apis.Books.v1.VolumesResource.GetRequest} Alt:无 国家:无 ETagAction:默认 {0} 字段:无 HttpMethod:“GET”键:无 记录器:{Google .Apis.Logging.NullLogger} MethodName: "get" OauthToken: Nothing Partner: Nothing PrettyPrint: Nothing Projection: Nothing QuotaUser: Nothing RequestParameters: Count = 12 RestPath: "volumes/{volumeId}" Service: {Google.Apis.Books. v1.BooksService} 服务:{Google.Apis.Books.v1.BooksService} 来源:Nothing UserIp:Nothing VolumeId:“9780330441230”