Comments (7)
@jrean & @SachinAgarwal1337: Good News!
The issue is related to how the pagination works. Google's API documents state:
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.
As such, adding a 2 second delay to the subsequent page requests fixes this issue. From my testing a 1 second delay was not enough to get around this, so 2 seconds is what I landed on. Because this is a timing related concern dictated by: a) google and b) how your code works - I don't think this should be 'fixed'. As not all projects will use the library in the same way, adding the delay in the library wouldn't always be necessary - therefor would slow down usage that doesn't need the delay.
For instance, with my project I've structured it so that I would collect all the results and then process and save them. However I am confident that if I changed my strategy to process the first page results, save them and THEN get the second page then the sleep wouldn't be necessary.
from google-places-api.
Dealing with the same issue here - seems that this feature isn't implemented by the library. The reason it's failing is that pagination requests only require the pagetoken
set based on the next_page_token
and the key
for authentication.
Edit: Details on this feature of the place API found here: https://developers.google.com/places/web-service/search#PlaceSearchPaging
EDIT 2: After further testing this what I shared here is not correct. The issue is not related to extra query parameters - Google's API actually just ignores the extras like you may expect. Leaving this intact but striking out the parts that are not accurate.
from google-places-api.
@SachinAgarwal1337 So it's pretty weird - I thought I could whip up a PR to add this feature, but something is going on. Basically I've been able to make the library support the feature however I'm still getting the "INVALID_REQUEST" status back.
Interestingly though when I enable debug mode for Guzzle the raw curl request looks valid. Not just that, but I can even take the text string from the debug output and it will work correctly in browser. If it weren't for using debug mode I'd be sure that I was still doing something super wrong. However, because the request URL works outside of the PHP script I know the URL being generated isn't the issue.
from google-places-api.
@mallardduck Thank you so much for figuring it out.
And as you mentioned, this doesn't look it needs fixing. I will be closing the issue the.
from google-places-api.
I confirm @mallardduck is the right patch to go. I ended up using a sleep()
of 2 seconds. 1 second not being enough.
@SachinAgarwal1337 maybe you could update the documentation to mention about this.
from google-places-api.
@mallardduck thanks, you saved my brain.
from google-places-api.
Very helpful!!
from google-places-api.
Related Issues (20)
- second param of Place Detail is not working
- Response returned with status: OVER_QUERY_LIMIT HOT 1
- How do i iterate over results?
- Support for Laravel 6 HOT 1
- Does this work with Laravel 6.x? HOT 3
- Is there a way to get the second page? HOT 6
- Clarity of the official doc HOT 1
- Support for PHP <= 7.1
- Error "API KEY is not specified"
- Support for retrieving place ratings, opening hours and reviews? HOT 3
- Support for Laravel 7+ HOT 1
- API KEY is not specified HOT 2
- PHP 5.6 support issue HOT 1
- Insert more than 1 keyword in Search Nearby HOT 1
- Response returned with status: REQUEST_DENIED HOT 1
- Add Support for PHP 8 HOT 3
- lat and long in autocomplete HOT 1
- Nearby Search doesn't return all fields documented in official Google documentation HOT 1
- Facade access in Laravel 10 HOT 2
- New Google Places API URL and method migration HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-places-api.