Reputation: 1336
First, I send a text search request to Google API for search results. I get 20 results and a token to get the next page of 20 results.
When I send the next request to Google API to get my next 20 results, it won't work if I dont sleep my PHP for at least 2 seconds.
How can I fix that to reduce my web application latency?
Additionnal details : I use the free version of Google API.
Here is the error I get when I send my query too fast :
<PlaceSearchResponse>
<status>INVALID_REQUEST</status>
</PlaceSearchResponse>
Upvotes: 0
Views: 225
Reputation: 182769
Your code is not in compliance with the API requirements. The API documentation is 100% clear that the attempt to retrieve the next page must be triggered by user action. The server is deliberately throttling you and if you keep it up, you will get personally contacted.
Thor Mitchell, Product Manager for the Google Maps API and Google Places API says:
The key point is that the request for another page of results must be triggered by some form of user action. It's not permitted to preload all 60 results server side and present them to the user all at once. We'll monitor request patterns to identify apps doing this and contact the developer to let them know that this is not permitted and that they must update their apps accordingly.
Upvotes: 3