is there a web service that can detect the country of a visitor in PHP? [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered开发者_如何学编程 with facts and citations.
Closed 7 years ago.
Improve this questionI use PHP and I want to know if there's a free web service that can detect the countries of my visitors. Right now i can get their IPs and I have downloaded some IPtables that relate some locations but i don.t think they're quite accurate. So if you are aware of some free webservice it would be just great. Thanks!
I have used the following SOAP GeoIPService to good effect from webservicex.net.
You will also of course need to enable SOAP support in your PHP config.
You could then try something like:
$client = new SoapClient("http://www.webservicex.net/geoipservice.asmx?WSDL");
$params = new stdClass;
$params->IPAddress = 'xxx.xxx.xxx.xxx';
$result = $client->GetGeoIP($params);
// Check for errors...
$country = $result->GetGeoIPResult->CountryName;
You could look around at MaxMind's open source solutions.
You could download and use this database http://software77.net/geo-ip/
精彩评论