Handbook
Web Service
Last updated by jinesh on Wed, 12/21/2005 - 07:05
NOTE: Read this first HTTP GET based Web Service is DOWN for now.
IP-to-Country provides a HTTP GET based Web Service to access country information for a particular IP Address.
The format of the request can be one of the following:
The first request will return the name of the country while the next two will return the 2 letter and 3 letter country code as defined in the ISO 3166 Country Codes Standard respectively.
In PHP, you can make the first request using the following code snippet:
IP-to-Country provides a HTTP GET based Web Service to access country information for a particular IP Address.
The format of the request can be one of the following:
1) http://ip-to-country.directi.com/country/name/IP_ADDRESS 2) http://ip-to-country.directi.com/country/code2/IP_ADDRESS 3) http://ip-to-country.directi.com/country/code3/IP_ADDRESSIn the above URL's IP_ADDRESS has to be replaced with the IP address for which you want to retrive country information.
The first request will return the name of the country while the next two will return the 2 letter and 3 letter country code as defined in the ISO 3166 Country Codes Standard respectively.
In PHP, you can make the first request using the following code snippet:
$handle = fopen("http://ip-to-country.directi.com/country/name/".$ip, 'r'); echo fgets($handle, 4096); fclose($handle);The other two requests can be achieved by simply replacing "name" with either "code2" or "code3".
