Php Geoplugin无法正常工作?

时间:2015-01-19 10:00:42

标签: php geolocation location

我遵循了以下所有指示:

http://www.geoplugin.com/webservices/php

然而我的一切都没有弹出页面只是空白(是的,我把它上传到我的在线服务器上)

<?php
$user_ip = getenv('REMOTE_ADDR');
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$user_ip"));
$city = $geo["geoplugin_city"];
$region = $geo["geoplugin_regionName"];
$country = $geo["geoplugin_countryName"];
echo "City: ".$city."<br>";
echo "Region: ".$region."<br>";
echo "Country: ".$country."<br>";
?>

唯一突然出现的是

城市:

地区:

国家:

没有答案。帮助

3 个答案:

答案 0 :(得分:0)

试试

$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=".$user_ip));

答案 1 :(得分:0)

array (
'geoplugin_request' => '112.133.198.126',
'geoplugin_status' => 206,
'geoplugin_credit' => 'Some of the returned data includes GeoLite data created by MaxMind, available from http://www.maxmind.com.',
'geoplugin_city' => '',
'geoplugin_region' => '',
'geoplugin_areaCode' => '0',
'geoplugin_dmaCode' => '0',
'geoplugin_countryCode' => 'IN',
'geoplugin_countryName' => 'India',
'geoplugin_continentCode' => 'AS',
'geoplugin_latitude' => '20',
'geoplugin_longitude' => '77',
'geoplugin_regionCode' => '',
'geoplugin_regionName' => NULL,
'geoplugin_currencyCode' => 'INR',
'geoplugin_currencySymbol' => '₨',
'geoplugin_currencySymbol_UTF8' => '₨',
'geoplugin_currencyConverter' => '61.62',
)

cityregion字段为空,仅获取country

答案 2 :(得分:0)

如果geoplugin.net响应良好,然后停止了,那么您已经超过了每分钟120个请求的免费查找限制。

这种情况经常发生在人们的网站被搜索引擎爬虫抓取时,这种爬虫很快可以使网站的geoplugin.net查询一分钟内超过120次。