需要替代geoip

我需要另一种方法来获取国家代码。这是一个使用geoip的脚本,请参阅func(
geoip_record_by_name
)。
$ip = $_SERVER['REMOTE_ADDR'];
$record = geoip_record_by_name($ip);
$countryid = $record['country_code'];
$countryname = $record["country_name"];
$countryallowed = array("AL", "AM", "AR", "AT", "AU", "AX", "BA", "BD", "BE", "BG", "BO", "BR", "BY", "CA", "CH", "CL", "CN", "CO", "CZ", "DE", "DJ", "DK", "DO", "DZ", "EC", "EE", "EG", "ES", "FI", "FR", "GB", "GE", "GF", "GL", "GR", "GY", "HK", "HR", "HU", "ID", "IE", "IL", "IN", "IR", "IS", "IT", "JO", "JP", "KH", "KP", "KR", "KZ", "LB", "LT", "LU", "LV", "LY", "MA", "MD", "ME", "MK", "ML", "MN", "MW", "MX", "MY", "NL", "NO", "NR", "NZ", "PE", "PH", "PL", "PR", "PT", "PW", "PY", "RE", "RO", "RS", "RU", "SE", "SG", "SI", "SK", "SR", "TH", "TR", "TW", "UA", "US", "UY", "UZ", "VE", "VN", "YE", "ZA");
    
已邀请:
你考虑过hostip.info吗?     
尝试使用SOAP:http://www.webservicex.net/geoipservice.asmx?op = GetGeoIP您所要做的就是:
$url = 'http://www.webservicex.net/geoipservice.asmx/GetGeoIP?IPAddress=';
if ($stream = fopen(url.$_SERVER['REMOTE_ADDR'], 'r')) {
    $soapResponse = stream_get_contents($stream, 1024);
    fclose($stream);
}

$xml = simplexml_load_string($soapResponse);

echo $xml->CountryCode; 
注意:我不知道有多少请求是免费的(每天,每个请求IP - 您的服务器,或所有请求)。     

要回复问题请先登录注册