示例#1
0
 public function getLocationFromIp()
 {
     $ip = $this->getIpAdress();
     if (empty($ip)) {
         throw new Exception('Error retrieving IP address');
     }
     // Use the method your server supports ( most of them only support curl )
     $xmlData = geoLocateIp::file_get_contents_curl($this->serviceLocateURL . $ip);
     //$xmlData = file_get_contents($this->serviceLocateURL.$ip);
     if (empty($xmlData)) {
         throw new Exception('Error retrieving xml');
     }
     $locationInfo = $this->parseLocationData($xmlData);
     return $locationInfo;
 }