あなたのIPアドレスの位置を決定することが時々必要。以下の実施例は、基準である
淘宝IPアドレスデータベース
IPアドレス依存のAPIを取得するためにインターフェース。非常に単純な、コードを見て:
<?php
/**
* 通过淘宝IP接口获取IP地理位置
* @param string $ip
* @return: string
**/
function getCity($ip)
{
$url="http://ip.taobao.com/service/getIpInfo.php?ip=".$ip;
$ipinfo=json_decode(file_get_contents($url));
if($ipinfo->code=='1'){
return false;
}
$city = $ipinfo->data->region.$ipinfo->data->city;
return $city;
}
// for example
print_r(getCity("121.207.247.202"));
福建省福州市
?>
再印刷のためのソースを示してください:
IP場所を属し得るため淘宝IPアドレスデータベースインタフェースを使用
http://www.ttlsa.com/html/1791.html
ます。https://my.oschina.net/766/blog/211172で再現