Could not load more than 60 results
OrelSokolov opened this issue · 3 comments
/home/oleg/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/google_places-0.27.0/lib/google_places/request.rb:325:in `parsed_response': GooglePlaces::InvalidRequestError (GooglePlaces::InvalidRequestError)
for code
require 'google_places'
API_KEY = "AIzaSyDCjp3CMfuSvKftEnyY_zSIXNkjpNbPM2Y"
@client = GooglePlaces::Client.new(API_KEY)
spots = @client.spots_by_query('Gap, London')
puts spots
next_page_token = spots.last.nextpagetoken
puts next_page_token
next_spots = @client.spots_by_pagetoken(next_page_token)
We can load more with miltipage: true
require 'google_places'
API_KEY = "AIzaSyDCjp3CMfuSvKftEnyY_zSIXNkjpNbPM2Y"
@client = GooglePlaces::Client.new(API_KEY)
spots = @client.spots_by_query('Gap, London', multipage: true)
puts spots
next_page_token = spots.last.nextpagetoken
puts next_page_token
next_spots = @client.spots_by_pagetoken(next_page_token)
@OrelSokolov can you give a more detailed reproduction path for this?
As far as I understand this is a Google API limitation, rather than a bug in the gem.
Some other people describe it eg. here joshtronic/php-googleplaces#5 .
Thanks @rennhak, for pointing that out.
The official documentation states the same:
next_page_token
contains a token that can be used to return up to 20 additional results. Anext_page_token
will not be returned if there are no additional results to display. The maximum number of results that can be returned is 60. There is a short delay between when anext_page_token
is issued, and when it will become valid.
Closing this issue as a won't fix.