Created
January 30, 2017 02:02
-
-
Save brianwebb01/13b5c832798a3664e3733b52fd45cb66 to your computer and use it in GitHub Desktop.
IP geolocation in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ip = "8.8.8.8"; | |
$r = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json")); | |
print_r($r); | |
/************** | |
stdClass Object | |
( | |
[ip] => 8.8.8.8 | |
[hostname] => google-public-dns-a.google.com | |
[city] => Mountain View | |
[region] => California | |
[country] => US | |
[loc] => 37.3860,-122.0838 | |
[org] => AS15169 Google Inc. | |
[postal] => 94035 | |
) | |
**************/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment