我正在使用 Google Place API 进行地点搜索:
https://developers.google.com/places/documentation/search
在api的第一次查询之后,我通过设置pagetoken来获取下一页。如果我在请求之间等待 2 秒,它会起作用,但我注意到如果我在上一个查询之后立即进行下一个查询,它会返回状态 INVALID_REQUEST。
这是某种速率限制吗?我在文档中的任何地方都没有看到这一点。
https://developers.google.com/places/usage
由于每个请求有 20 个位置,因此获取 100 个结果的列表将花费 10 秒以上,这对于使用应用程序的人来说是很长的时间。
最佳答案
它被记录在案,参见 documentation
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-maps - Google Places API 上的分页返回状态 INVALID_REQUEST,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21265756/