【问题标题】:Google Books API Limit ResultsGoogle Books API 限制结果
【发布时间】:2017-09-07 09:55:36
【问题描述】:

有没有办法限制 Google Books API 返回的结果?

例如以下网址:

https://www.googleapis.com/books/v1/volumes?q=isbn:0751538310

返回以下内容:

"kind": "books#volumes",
 "totalItems": 1,
 "items": [
  {
   "kind": "books#volume",
   "id": "ofTsHAAACAAJ",
   "etag": "K6a+5IuCMD0",
   "selfLink": "https://www.googleapis.com/books/v1/volumes/ofTsHAAACAAJ",
   "volumeInfo": {
    "title": "Panic",
    "authors": [
     "Jeff Abbott"
    ],
    "publisher": "Grand Central Publishing",
    "publishedDate": "2006",
    "description": "Things are going well for young film-maker Evan Casher - until he receives an urgent phonecall from his mother, summoning him home. He arrives to find her brutally murdered body on the kitchen floor and a hitman lying in wait for him. It is then he realises his whole life has been a lie. His parents are not who he thought they were, his girlfriend is not who he thought she was, his entire existence an ingeniously constructed sham. And now that he knows it, he is in terrible danger. So he is catapulted into a violent world of mercenaries, spies and terrorists. Pursued by a ruthless band of killers who will stop at nothing to keep old secrets buried, Evan's only hope for survival is to discover the truth behind his past. An absolute page-turner, Panic has been acclaimed as one of the most exciting thrillers of recent years.",
    "industryIdentifiers": [
     {
      "type": "ISBN_10",
      "identifier": "0751538310"
     },
     {
      "type": "ISBN_13",
      "identifier": "9780751538311"
     }
    ],
    "readingModes": {
     "text": false,
     "image": false
    },
    "pageCount": 408,
    "printType": "BOOK",
    "categories": [
     "Austin (Tex.)"
    ],
    "maturityRating": "NOT_MATURE",
    "allowAnonLogging": false,
    "contentVersion": "preview-1.0.0",
    "imageLinks": {
     "smallThumbnail": "http://books.google.com/books/content?id=ofTsHAAACAAJ&printsec=frontcover&img=1&zoom=5&source=gbs_api",
     "thumbnail": "http://books.google.com/books/content?id=ofTsHAAACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api"
    },
    "language": "en",
    "previewLink": "http://books.google.co.uk/books?id=ofTsHAAACAAJ&dq=isbn:0751538310&hl=&cd=1&source=gbs_api",
    "infoLink": "http://books.google.co.uk/books?id=ofTsHAAACAAJ&dq=isbn:0751538310&hl=&source=gbs_api",
    "canonicalVolumeLink": "https://books.google.com/books/about/Panic.html?hl=&id=ofTsHAAACAAJ"
   },
   "saleInfo": {
    "country": "GB",
    "saleability": "NOT_FOR_SALE",
    "isEbook": false
   },
   "accessInfo": {
    "country": "GB",
    "viewability": "NO_PAGES",
    "embeddable": false,
    "publicDomain": false,
    "textToSpeechPermission": "ALLOWED",
    "epub": {
     "isAvailable": false
    },
    "pdf": {
     "isAvailable": false
    },
    "webReaderLink": "http://books.google.co.uk/books/reader?id=ofTsHAAACAAJ&hl=&printsec=frontcover&output=reader&source=gbs_api",
    "accessViewStatus": "NONE",
    "quoteSharingAllowed": false
   },
   "searchInfo": {
    "textSnippet": "An absolute page-turner, Panic has been acclaimed as one of the most exciting thrillers of recent years."
   }
  }
 ]

有什么方法可以只返回标题描述?我认为它可以提高我的 Web 应用程序的性能。

我查看了partial response,但它似乎不起作用。

在 URL 查询参数中包含我的 API 密钥。

谢谢

【问题讨论】:

    标签: php mysql rest google-books


    【解决方案1】:

    我根据部分响应文档添加了参数。

    查看以下链接中的参数:

    https://www.googleapis.com/books/v1/volumes?q=isbn:0751538310&fields=items(volumeInfo/description,volumeInfo/title)

    它会返回:

    {
     "items": [
      {
       "volumeInfo": {
        "title": "Panic",
        "description": "Things are going well for young film-maker Evan Casher - until he receives an urgent phonecall from his mother, summoning him home. He arrives to find her brutally murdered body on the kitchen floor and a hitman lying in wait for him. It is then he realises his whole life has been a lie. His parents are not who he thought they were, his girlfriend is not who he thought she was, his entire existence an ingeniously constructed sham. And now that he knows it, he is in terrible danger. So he is catapulted into a violent world of mercenaries, spies and terrorists. Pursued by a ruthless band of killers who will stop at nothing to keep old secrets buried, Evan's only hope for survival is to discover the truth behind his past. An absolute page-turner, Panic has been acclaimed as one of the most exciting thrillers of recent years."
       }
      }
     ]
    }
    

    【讨论】:

      【解决方案2】:

      最大结果

      在您的查询中包含此内容。 5 只是一个整数。 &maxResults=5

      Google 将帮助您使用这个名为 try it 的网站 API 创建您的 API。 https://developers.google.com/books/docs/v1/reference/volumes/list?apix=true#try-it

      【讨论】:

        【解决方案3】:

        也许响应为时已晚,但您需要在访问 API 之前激活它。当您尝试访问它时,它会说从带有一些项目 ID 的控制台激活它。只需复制该网址,它就会直接将您带到您的仪表板,在那里您可以找到您的激活按钮帖子,您可以访问具有所需属性的部分响应。

        【讨论】:

          猜你喜欢
          • 2016-05-20
          • 2012-07-07
          • 1970-01-01
          • 1970-01-01
          • 2015-10-28
          • 1970-01-01
          • 2023-03-22
          • 1970-01-01
          • 2015-08-11
          相关资源
          最近更新 更多