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": [], diff --git a/src/GoogleMaps/Geocoder.php b/src/GoogleMaps/Geocoder.php index 7da2655..17afc96 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. @@ -103,10 +103,13 @@ 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()); + $stream = $client->send(); - + $body = Json::decode($stream->getBody(), Json::TYPE_ARRAY); $hydrator = new ArraySerializable(); @@ -127,7 +130,7 @@ public function geocode(Request $request) $resultSet->addElement($result); } $response->setResults($resultSet); - + return $response; } } \ No newline at end of file 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