Helper/Geolocation.php
private function getLocationJson($ip, $apiKey)
    {

        $endpoint = sprintf($this->endpointFormat, $ip, $apiKey);

        $client = $this->httpClientFactory->create();
        $client->setUri($endpoint);
        $client->setConfig(['maxredirects' => 0, 'timeout' => 30]);

        // Dependant on third party API, wrapping in try/catch block.
        // On error notify bugsnag and proceed (return null)
        try {
            return $client->request()->getBody();
        } catch (\Exception $e) {
            $this->bugsnag->notifyException($e);
            return null;
        }
    }
private function getLocationJson($ip, $apiKey)
    {

        $endpoint = sprintf($this->endpointFormat, $ip, $apiKey);

        $client = $this->httpClientFactory->create();
        $client->setUri($endpoint);
        $client->setConfig(['maxredirects' => 0, 'timeout' => 30]);

        // Dependant on third party API, wrapping in try/catch block.
        // On error notify bugsnag and proceed (return null)
        try {
            return $client->request()->getBody();
        } catch (\Exception $e) {
            $this->bugsnag->notifyException($e);
            return null;
        }
    }
private function getLocationJson ( $ ip , $ apiKey ) { $ endpoint = sprintf ( $ this -> endpointFormat , $ ip , $ apiKey ) ; $ client = $ this -> httpClientFactory -> create ( ) ; $ client -> setUri ( $ endpoint ) ; $ client -> setConfig ( [ 'maxredirects' => 0 , 'timeout' => 30 ] ) ; // Dependant on third party API, wrapping in try/catch block. // On error notify bugsnag and proceed (return null) try { return $ client -> request ( ) -> getBody ( ) ; } catch ( \ Exception $ e ) { $ this -> bugsnag -> notifyException ( $ e ) ; return null ; } }
Make a Geolocation API call

@param string $ip        The IP address
@param $apiKey           ipstack.com API key
@return null|string      JSON formated response
@throws \Zend_Http_Client_Exception
Make a Geolocation API call