Basically the code is something like this:

 

So we are using the GeoPlugin API to retrieve the Country code. You can also get the full country name, state, city, continent and some other stuff. Here is a simple dump of the data returned from the site:

For more info and explanations and more complicated code check Chris Wiegman post on this topic.

Leave a comment

Your email address will not be published. Required fields are marked *