Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are free, easy APIs you can use, like those:</p> <ul> <li><a href="http://ipinfodb.com/ip_location_api.php" rel="nofollow noreferrer">http://ipinfodb.com/ip_location_api.php</a></li> <li><a href="http://www.ipgeo.com/api/" rel="nofollow noreferrer">http://www.ipgeo.com/api/</a></li> <li><a href="http://ip2.cc/" rel="nofollow noreferrer">http://ip2.cc/</a></li> <li><a href="http://www.geobytes.com/IpLocator.htm" rel="nofollow noreferrer">http://www.geobytes.com/IpLocator.htm</a></li> <li><a href="https://iplocate.io/" rel="nofollow noreferrer">https://iplocate.io/</a></li> <li>and plenty others.</li> </ul> <p>Which one looks the most trustworthy is up to you :)</p> <p>Otherwise, there are scripts which are based on local databases on your server. The database data needs to be updated regularly, though. Check out this one:</p> <ul> <li><a href="http://phpweby.com/software/ip2country" rel="nofollow noreferrer">http://phpweby.com/software/ip2country</a></li> </ul> <p>HTH!</p> <p><strong>Edit:</strong> And of course, depending on your project you might want to look at <a href="http://html5demos.com/geo" rel="nofollow noreferrer">HTML5 Location</a> features. You can't use them yet on the Internet Explorer (IE9 will support it, long way to go yet), but in case your audience is mainly on mobile devices or using Safari/Firefox it's definitely worth to look at it!</p> <p>Once you have the coordinates, you can reverse geocode them to a country code. Again there are APIs like this one:</p> <ul> <li>Example: <a href="http://ws.geonames.org/countryCode?lat=47.03&amp;lng=10.2" rel="nofollow noreferrer">http://ws.geonames.org/countryCode?lat=47.03&amp;lng=10.2</a> </li> <li>More APIs: <a href="http://www.geonames.org/export/ws-overview.html" rel="nofollow noreferrer">http://www.geonames.org/export/ws-overview.html</a></li> </ul> <p><strong>Update, April 2013</strong><br> Today I would recommend using <a href="https://github.com/willdurand/Geocoder" rel="nofollow noreferrer">Geocoder</a>, a PHP library which makes it very easy to geocode ip addresses as well as postal address data.</p> <p>***Update, September 2016<br> Since Google's privacy politics has changed, you can't use HTML5 Geolocation API if your server doesn't have HTPPS certificate or user doesn't allow you check his location. So now you can use user's IP and check in in PHP or get HTTPS certificate.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload