Skip to content

Instantly share code, notes, and snippets.

@fuckuppro
Created January 28, 2016 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fuckuppro/87a3e6a8ca06a74d2a57 to your computer and use it in GitHub Desktop.
Save fuckuppro/87a3e6a8ca06a74d2a57 to your computer and use it in GitHub Desktop.
best geo ip freegeoip.net/json/192.168.1.1
<?
$ip = '192.168.11.5';
if($ch = curl_init()){
$url = "http://freegeoip.net/json/". $ip;
$headers = array(
"Content-type: application/json",
"Accept: application/json",
"Accept-Language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = curl_exec($ch);
if (curl_errno($ch)) {
// curl_error($ch);
} else {
$arData = json_decode($data, true) ;
}
curl_close($ch);
}
print_r($arData);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment