
The obvious limitation of the Web service approach is the request speed. The only thing to care about is when you send cross-domain AJAX requests you maybe restricted if you do not send the right set of CORS headers from the server. Since the Web service call can return the response in the JSON format, which is native JavaScript notation, it's not so hard to make a call and process the result. It can potentially be used not only on server-side with help of PHP, but also at client-side by JavaScript. You are just ready to go.Īnother advantage of the Web service comes from its nature.
#IP2LOCATION OF MY LAPTOP INSTALL#
The advantage of this approach is that there is no need to install anything or access any kind of a local file or database. The service can be currency exchange rate for a given date and currency, or, as in our example, you can send an IP address as text and get the location information. In short, a Web service is a URL you call with a list of parameters and get results back, usually in a format like XML or JSON. So in our example we are going to use this approach to make the calls to the Web service. This will output "Hello world" of course. There is an easy way to run single PHP commands from command line: you just need to run PHP interpreter with "-r" flag like this: php -r 'echo "Hello world" '


The Web service access has a paid version, but even the free demo version is enough to play with this solution.
#IP2LOCATION OF MY LAPTOP CODE#
To cut the long story short, it can be done with PHP one-liner (one line of code that solves the task) if we just query IP2Location Web service. I don't have any database or IP2Location binary file installed on my laptop that I could query, and I want to check if my current IP address can be converted to a location. Let's use this example to check how easy is the IP2Location Web service that helps to detect geo location just by the given IP address. I am writing this article from Borispol airport which is close to Kiev city (Ukraine).
