Google Places API 上的分页返回状态 INVALID_REQUEST [英] Paging on Google Places API returns status INVALID_REQUEST

查看:34
本文介绍了Google Places API 上的分页返回状态 INVALID_REQUEST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Google Place API 进行地点搜索:

I'm using the Google Place API for place search:

https://developers.google.com/places/documentation/search

在api的第一次查询之后,我通过设置pagetoken来获取下一页.如果我在请求之间等待 2 秒,它会起作用,但我注意到如果我在上一个查询之后立即进行下一个查询,它会返回状态 INVALID_REQUEST.

After the first query of the api, I'm getting the next page by setting the pagetoken. If I wait 2 seconds between requests, it works, but I notice that if I make the next query right after the previous one, it returns the status INVALID_REQUEST.

这是某种速率限制吗?我在文档中的任何地方都没有看到这一点.

Is this some kind of rate limiting? I don't see this anywhere in the documentation.

https://developers.google.com/places/usage

由于每个请求有 20 个位置,因此获取 100 个结果的列表将花费 10 秒以上的时间,这对于使用应用程序的人来说是很长的时间.

Since each request has 20 places, getting a list of 100 results will take over 10 seconds which is a long time for someone to wait using an app.

推荐答案

有文档说明,见文档

默认情况下,每次附近搜索或文本搜索最多返回 20 个场所结果.询问;但是,每次搜索最多可以返回 60 个结果,分为三个页面.如果您的搜索将返回 20 多个,那么搜索响应将包含一个额外的值 — next_page_token.将 next_page_token 的值传递给 pagetoken 参数新搜索以查看下一组结果.如果 next_page_token 为空,或者不是返回,则没有进一步的结果.之间有一个短暂的延迟next_page_token 已发出,何时生效.请求之前的下一页可用将返回一个 INVALID_REQUEST 响应. 使用相同的重试请求next_page_token 将返回下一页结果.

By default, each Nearby Search or Text Search returns up to 20 establishment results per query; however, each search can return as many as 60 results, split across three pages. If your search will return more than 20, then the search response will include an additional value — next_page_token. Pass the value of the next_page_token to the pagetoken parameter of a new search to see the next set of results. If the next_page_token is null, or is not returned, then there are no further results. There is a short delay between when a next_page_token is issued, and when it will become valid. Requesting the next page before it is available will return an INVALID_REQUEST response. Retrying the request with the same next_page_token will return the next page of results.

这篇关于Google Places API 上的分页返回状态 INVALID_REQUEST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆