Spaces:
No application file
No application file
File size: 1,191 Bytes
d2897cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<?php
namespace Mautic\CoreBundle\IpLookup;
class IP2LocationAPILookup extends AbstractRemoteDataLookup
{
public function getAttribution(): string
{
return '<a href="http://IP2Location.com/" target="_blank">IP2Location </a> web service WS9 Package only.';
}
protected function getUrl(): string
{
return "api.ip2location.com/?ip={$this->ip}&key={$this->auth}&package=WS9&format=json";
}
protected function parseResponse($response)
{
try {
$record = json_decode($response);
if (isset($record->country_name)) {
$this->country = $record->country_name;
$this->region = $record->region_name;
$this->city = $record->city_name;
$this->latitude = $record->latitude;
$this->longitude = $record->longitude;
// $this->timezone = $record->location->timeZone;
$this->zipcode = $record->zip_code;
}
} catch (\Exception $exception) {
if ($this->logger) {
$this->logger->warning('IP LOOKUP: '.$exception->getMessage());
}
}
}
}
|