From fc72a9d78ee067236e5c64cd637fa779cc00d82a Mon Sep 17 00:00:00 2001 From: Michelangelo Turillo Date: Mon, 31 Aug 2015 17:19:56 +0200 Subject: [PATCH 1/4] Added the "key parameter" for the google private key --- src/GoogleMaps/Request.php | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/GoogleMaps/Request.php b/src/GoogleMaps/Request.php index feacba1..e3297e0 100644 --- a/src/GoogleMaps/Request.php +++ b/src/GoogleMaps/Request.php @@ -2,7 +2,7 @@ /** * This file is part of Geoxygen * - * (c) 2012 Cédric DERUE + * (c) 2012 Cdric DERUE * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -82,6 +82,13 @@ class Request * @var string */ protected $signature; + + /** + * Key for Google Maps for Business + * + * @var string + */ + protected $key; /** * Contructor @@ -189,6 +196,22 @@ private function setSignature($signature) $this->signature = $signature; } + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @param string $key + */ + public function setKey($key) + { + $this->key = $key; + } + /** * @return the $region */ @@ -246,8 +269,8 @@ public function sign($privateKey) { $url = implode('?', array(Geocoder::GOOGLE_GEOCODING_API_PATH, $this->getUrlParameters())); $decodePrivateKey = $this->base64DecodeUrlSafe($privateKey); - - $sign = hash_hmac("sha1", $url, $decodePrivateKey, true); + + $sign = hash_hmac("sha1", $url, $decodePrivateKey, true); $signature = $this->base64EncodeUrlSafe($sign); $this->setSignature($signature); @@ -282,7 +305,7 @@ private function base64DecodeUrlSafe($value) public function getUrlParameters() { $requiredParameters = array('address', 'latlng', 'components', 'sensor'); - $optionalParameters = array('bounds', 'language', 'client', 'signature', 'region', 'components'); + $optionalParameters = array('bounds', 'language', 'client', 'signature', 'region', 'components','key'); $url = ''; foreach ($requiredParameters as $parameter) { @@ -312,6 +335,7 @@ public function getUrlParameters() $url .= '&' . $option . '=' . urlencode($optionParam); } } + return $url; } } \ No newline at end of file From b6f56ddc811b5d4d1da88cc87605a9c46c54114b Mon Sep 17 00:00:00 2001 From: Michelangelo Turillo Date: Mon, 31 Aug 2015 17:37:09 +0200 Subject: [PATCH 2/4] Https scheme fixed --- src/GoogleMaps/Geocoder.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/GoogleMaps/Geocoder.php b/src/GoogleMaps/Geocoder.php index 7da2655..8180c8a 100644 --- a/src/GoogleMaps/Geocoder.php +++ b/src/GoogleMaps/Geocoder.php @@ -2,7 +2,7 @@ /** * This file is part of Geoxygen * - * (c) 2012 Cédric DERUE + * (c) 2012 Cdric DERUE * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -104,9 +104,11 @@ public function geocode(Request $request) $uri->setQuery($urlParameters); $client = $this->getHttpClient(); $client->resetParameters(); + $uri->setScheme("https"); $client->setUri($uri->toString()); + $stream = $client->send(); - + $body = Json::decode($stream->getBody(), Json::TYPE_ARRAY); $hydrator = new ArraySerializable(); @@ -127,7 +129,7 @@ public function geocode(Request $request) $resultSet->addElement($result); } $response->setResults($resultSet); - + return $response; } } \ No newline at end of file From 20ff748fe10484259319c865bcf7f6e1c46b324f Mon Sep 17 00:00:00 2001 From: Michelangelo Turillo Date: Mon, 31 Aug 2015 17:58:07 +0200 Subject: [PATCH 3/4] composer name hasn been changed --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4ac0eda..fe36ac6 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "cderue/googlemaps", + "name": "shinesoftware/googlemaps", "description": "A Zend Framework module that provides a PHP wrapper to the Google Maps Geocoding API", "type": "module", "keywords": [], From 0ea86296f326a0acf4a61787e3ce76cd4d0e90be Mon Sep 17 00:00:00 2001 From: Michelangelo Turillo Date: Mon, 31 Aug 2015 18:16:06 +0200 Subject: [PATCH 4/4] sslcapath workaround --- src/GoogleMaps/Geocoder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/GoogleMaps/Geocoder.php b/src/GoogleMaps/Geocoder.php index 8180c8a..17afc96 100644 --- a/src/GoogleMaps/Geocoder.php +++ b/src/GoogleMaps/Geocoder.php @@ -103,6 +103,7 @@ public function geocode(Request $request) $uri->setQuery($urlParameters); $client = $this->getHttpClient(); + $client->setAdapter('Zend\Http\Client\Adapter\Curl'); $client->resetParameters(); $uri->setScheme("https"); $client->setUri($uri->toString());