Sometimes it's useful to locate where a certain IP address is located. Usually this isn't really that accurate but at least it gives you a general idea for stats or marketing research. I've written a simple php function that uses curl to query a IP address location database for the location info. In the function I specify that I want a JSON data structure containing the location information. I chose JSON over the XML alternative just for ease of use. The object that we get returned needs to be referenced in a specific kind of way. I show how under the function.
Hopefully theres no confusion there.
This entry was posted on Wednesday, June 10th, 2009 at and is filed under . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
A similar operation could be performed in a better way at the private search engine site http://www.aafter.com, where you just need to type the phrase IP? and the search engine returns the physical location.
That does work. But the whole point is to do this in php for any ip address. Not get my own IP location.
@GoGoGa I should definitely do that. Good advice.
Good information. Your are right this is a programmatic way to find out the geo location from IP. However, for a quick lookup one can type the IP address at the AAfter search box, it returns location, ISP info, and if the IP is trusted.