Sunday, September 8, 2013

Get country name using IP address in php

Get country name using IP address in php

Get country name using IP address in php
Get country name using IP address in php

Geo IP Lookup API

The Geo IP Lookup API provides a variety of lookup methods. Below we will outline the different ways to get data from the Geo IP Lookup tool along with code samples of each:

HTML

The simplest way to get data from the API. There are 4 types of HTML output: countrycodecountrylocale, and full.
countrycode
Specify the ipaddress variable and the output variable of countrycode and retrieve the country code for any IP address
http://geoiplookup.net/geoapi.php?output=countrycode&ipaddress=96.254.141.142 will return the following:
Country: US
country
Specify the ipaddress variable and the output variable of country and retrieve the country name for any IP address
http://geoiplookup.net/geoapi.php?output=country&ipaddress=96.254.141.142 will return the following:
Country: United States
locale
Specify the ipaddress variable and the output variable of locale and retrieve the city, region, and country for any IP address
http://geoiplookup.net/geoapi.php?output=locale&ipaddress=96.254.141.142 will return the following:
Country: United States (US)
City: Tampa, Region: FL
full
Specify the ipaddress variable and the output variable of full and retrieve the city, region, country, and latitude and longitude for any IP address
http://geoiplookup.net/geoapi.php?output=full&ipaddress=96.254.141.142 will return the following:
Country: United States (US)
City: Tampa, Region: FL
Latitude: 27.9178 Longitude: -82.3799

JSON

Specify the ipaddress variable and the output variable of json and retrieve a full JSON encoded result set.
http://geoiplookup.net/geoapi.php?output=json&ipaddress=96.254.141.142 will return the following:
{“countryName”:”United States”,”countryCode”:”US”,”cityName”:”Tampa”, “regionName”:”FL”,”areaCode”:”813″,”latitude”:27.9178,”longitude”:-82.3799,”ip”:”96.254.141.142″}

XML

Specify the ipaddress variable and the output variable of xml and receive a full result set in XML format.
http://geoiplookup.net/geoapi.php?output=xml&ipaddress=96.254.141.142

With all API requests, leaving out the ipaddress variable will return a result set using the calling host’s IP address.

Source : http://www.geoiplookup.net/api.php

No comments:

Post a Comment