あなたはそれはあなたが非常に多くを持っていますhttp://www.geoplugin.net/
$xml = simplexml_load_file("http://www.geoplugin.net/xml.gp?ip=".getRealIpAddr());
echo $xml->geoplugin_countryName ;
echo "<pre>" ;
foreach ($xml as $key => $value)
{
echo $key , "= " , $value , " \n" ;
}
function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
出力
United States
geoplugin_city= San Antonio
geoplugin_region= TX
geoplugin_areaCode= 210
geoplugin_dmaCode= 641
geoplugin_countryCode= US
geoplugin_countryName= United States
geoplugin_continentCode= NA
geoplugin_latitude= 29.488899230957
geoplugin_longitude= -98.398696899414
geoplugin_regionCode= TX
geoplugin_regionName= Texas
geoplugin_currencyCode= USD
geoplugin_currencySymbol= $
geoplugin_currencyConverter= 1
から、単純なAPIを使用することができますあなたが周りに遊ぶことができるオプション
ありがとう
:)
簡単に、ユーザーに尋ねます。唯一の信頼できる方法です。 –
ダゴンが正しいです。あなたが望む場所サービスをIPに使うことはできますが、100%正確なものはなく、プロキシの種類によっては検出できない(したがって、間違ったIPがチェックされています)。私が思うが、位置情報サービスは試してみる価値がないということではありません。 – Corbin