Get Address,City,County From IP address
First you must create account on Here to get API_Key
you can read document from Here
once you get API_Key you can use Code to get data :
you can read document from Here
once you get API_Key you can use Code to get data :
private String GetCityName(string IP)
{
string _City = "";
try
{
string _URL = null;
string _ApiKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
_URL = "http://api.ipinfodb.com/v3/ip-country/?key=" + _ApiKey + "&format=xml&ip=" + IP;
//Get google response as XML doc
dynamic xmlDoc = new System.Xml.XmlDocument();
xmlDoc.Load(_URL);
System.Xml.XmlNode _root = xmlDoc.DocumentElement;
System.Xml.XmlNodeList _CityName = xmlDoc.GetElementsByTagName("cityName");
System.Xml.XmlElement _CityNameElement = (System.Xml.XmlElement)_CityName.Item(0);
_City = _CityNameElement.FirstChild.Value;
}
catch (Exception ex)
{
_City = "CANADA";
}
//End Try
return _City;
}
Comments
Post a Comment