问题描述
我使用 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 将返回下一页结果.
这篇关于Google Places API 上的分页返回状态 INVALID_REQUEST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!