3

I'm trying to get the Google Books API to return the Book Edition number. IE: 3rd Edition, 7th, Illustrated, ect.

Using the following code, I can basically get everything I could ever want to find out about the book by changing or adding a few objectType changes. EXCEPT the edition type.

<html>
<head>
<title>Books API Example</title>
</head>
 <body>
   <div id="content"></div>
   <script>
     function handleResponse(response) {
     for (var i = 0; i < response.items.length; i++) {
       var item = response.items[i];
       // in production code, item.text should have the HTML entities escaped.
       document.getElementById("content").innerHTML += "<br>" + item.volumeInfo.title + " : " + item.volumeInfo.subtitle
    + "<br>" + item.volumeInfo.authors + " "
    + "<br>" + "<img src='" + item.volumeInfo.imageLinks.thumbnail + "'> <br>";
  }
}
</script>
   <script src="https://www.googleapis.com/books/v1/volumes?q=isbn:1435497783&callback=handleResponse"></script>
 </body>

Here are the parameters https://developers.google.com/books/docs/v1/reference/volumes

Anyone know anything about the edition for the volume? EDIT: Also, would anyone be willing to show me how I can do basically an 'if' statement for a subtitle. If the book has one, I want to display it. But if it doesn't, I dont want undefined sitting next to the title.

4

2 回答 2

1

遗憾的是,我认为 API 不会公开这些信息。

于 2013-02-21T17:40:31.487 回答
0

因为我自己正在使用 API,所以才遇到这个问题。响应以 JSON 对象的形式出现。查看响应并以您选择的语言创建必要的类。我正在使用 C#,所以我使用 json2csharp.com 为我创建类。一旦你有了这个,你可以将响应序列化到你的类中,这应该很容易让你看到返回的卷有字幕或任何其他属性。

请注意,我在使用 API 时正在从服务器端执行 Web 请求。这是因为我在处理服务器上的响应方面有更大的灵活性,而不是在客户端浏览器中使用一些漂亮的 javascript(那和我的 c# 技能比我的 JS 技能强得多;-))

于 2013-02-08T19:03:03.797 回答