Skip to content

Commit b5e5740

Browse files
Updated to match API response changes.
1 parent 0968e0b commit b5e5740

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ To begin, an API key is required for this module to function. Find further infor
1818
require_once 'class.IP2LocationAPI.php';
1919

2020
$apiKey = 'YOUR_API_KEY';
21-
$package = 'WS24'; // Package: WS1 - WS24
21+
$package = 'WS25'; // Package: WS1 - WS25
2222
$useSSL = false; // Use HTTP or HTTPS (Secure, but slower)
2323

2424
$ip = '8.8.8.8';
@@ -64,6 +64,8 @@ echo 'Weather Station Name : ' . $location->weatherStationName . "\n";
6464
echo 'Mobile Brand : ' . $location->mobileBrand . "\n";
6565
echo 'Elevation : ' . $location->elevation . "\n";
6666
echo 'Usage Type : ' . $location->usageType . "\n\n";
67+
echo 'Address Type : ' . $location->addressType . "\n\n";
68+
echo 'Category : ' . $location->category . "\n\n";
6769

6870
if ($location->continent) {
6971
echo 'Continent Name : ' . $location->continent['name'] . "\n";
@@ -121,4 +123,3 @@ if ($location->timeZoneInfo) {
121123
echo '</pre>';
122124
```
123125

124-

class.IP2LocationAPI.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class IP2LocationAPI
2222
public $mobileBrand;
2323
public $elevation;
2424
public $usageType;
25+
public $addressType;
26+
public $category;
2527

2628
public $continent = [
2729
'name' => '',
@@ -132,7 +134,7 @@ public function query($ip)
132134
return false;
133135
}
134136

135-
if (isset($json->response)) {
137+
if ($json->response != 'OK') {
136138
return false;
137139
}
138140

@@ -156,6 +158,8 @@ public function query($ip)
156158
$this->mobileBrand = (string) (isset($json->mobile_brand)) ? $json->mobile_brand : 'N/A';
157159
$this->elevation = (int) (isset($json->elevation)) ? $json->elevation : 'N/A';
158160
$this->usageType = (string) (isset($json->usage_type)) ? $json->usage_type : 'N/A';
161+
$this->addressType = (string) (isset($json->address_type)) ? $json->address_type : 'N/A';
162+
$this->category = (string) (isset($json->category)) ? $json->category : 'N/A';
159163

160164
if (isset($json->continent)) {
161165
$this->continent = [
@@ -232,7 +236,7 @@ private function get($url)
232236
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
233237
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
234238
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
235-
curl_setopt($ch, CURLOPT_USERAGENT, 'IP2LocationAPI_PHP-1.1.0');
239+
curl_setopt($ch, CURLOPT_USERAGENT, 'IP2LocationAPI_PHP-1.2.0');
236240
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
237241
$response = curl_exec($ch);
238242

example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require_once 'class.IP2LocationAPI.php';
44

55
$apiKey = 'YOUR_API_KEY';
6-
$package = 'WS24'; // Package: WS1 - WS24
6+
$package = 'WS25'; // Package: WS1 - WS25
77
$useSSL = false; // Use HTTP or HTTPS (Secure, but slower)
88

99
$ip = '8.8.8.8';

0 commit comments

Comments
 (0)