-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_usage.php
More file actions
35 lines (26 loc) · 859 Bytes
/
basic_usage.php
File metadata and controls
35 lines (26 loc) · 859 Bytes
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
<?php
declare(strict_types=1);
require_once __DIR__ . '/../vendor/autoload.php';
use IPLocate\Exceptions\IPLocateException;
use IPLocate\IPLocate;
// Get your free API key from https://iplocate.io/signup
$apiKey = 'your-api-key-here';
try {
// Create a new client
$client = new IPLocate($apiKey);
// Look up an IP address
$result = $client->lookup('8.8.8.8');
echo "IP: {$result->ip}\n";
if ($result->country) {
echo "Country: {$result->country}\n";
}
if ($result->city) {
echo "City: {$result->city}\n";
}
// Check privacy flags
echo 'Is VPN: ' . ($result->privacy->isVpn ? 'Yes' : 'No') . "\n";
echo 'Is Proxy: ' . ($result->privacy->isProxy ? 'Yes' : 'No') . "\n";
} catch (IPLocateException $e) {
echo "Error: {$e->getMessage()}\n";
echo "HTTP Status: {$e->getCode()}\n";
}