From f2eddb80368f04fd10d38b4c67a071232b8606f9 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Wed, 26 Feb 2014 10:06:20 -0500 Subject: [PATCH] Implemented pagetoken and dropped unsetting Thanks to @bristweb for this update! Seems I failed to properly implement the pagetoken and there was a block of code where I was unsetting parameters because at the time it seemed as if Google was not ignoring them as they claimed they would (a/k/a they "lied"). I'm not overly fond of the `sleep(3)` but it's a necessary evil because Google's pagetokens are not immediately available (as per https://developers.google.com/places/documentation/search#PlaceSearchPaging). My thought would be to perhaps create a loop that will retry X times every Y seconds to better compensate for inconsistent activation times on Google's end. Closes #4 (for the most part) --- GooglePlaces.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/GooglePlaces.php b/GooglePlaces.php index cfffd8a..0ab81e5 100644 --- a/GooglePlaces.php +++ b/GooglePlaces.php @@ -44,12 +44,6 @@ class GooglePlaces // Except these variables if (!in_array($variable, array('base_url', 'method', 'output', 'pagetoken', 'response'))) { - // Google lied, all other parameters aren't ignored, they need to be suppressed - if ($this->pagetoken !== null) - { - $this->$variable == null; - } - // Assuming it's not null if ($value !== null) { @@ -179,6 +173,12 @@ class GooglePlaces } } + if ($this->pagetoken !== null) + { + $parameters['pagetoken'] = $this->pagetoken; + sleep(3); + } + // Couldn't seem to get http_build_query() to work right so... $querystring = '';