Exemplo n.º 1
0
 public static string GetUserLocByIp(string ip)
 {
     General.Classes.IpInfo ipInfo = new General.Classes.IpInfo();
     try
     {
         string info = new WebClient().DownloadString("http://ipinfo.io/" + ip);
         ipInfo = JsonConvert.DeserializeObject <General.Classes.IpInfo>(info);
         StringInfo msdsd = new StringInfo(ipInfo.Loc);
         ipInfo.Loc = msdsd.String;
     }
     catch (Exception)
     {
         ipInfo.Loc = null;
     }
     return(ipInfo.Loc);
 }
Exemplo n.º 2
0
        public static string GetUserCountryByIp(string ip)
        {
            General.Classes.IpInfo ipInfo = new General.Classes.IpInfo();
            try
            {
                string info = new WebClient().DownloadString("http://ipinfo.io/" + ip);
                ipInfo = JsonConvert.DeserializeObject <General.Classes.IpInfo>(info);
                RegionInfo myRI1 = new RegionInfo(ipInfo.Country);
                ipInfo.Country = myRI1.EnglishName;
            }
            catch (Exception)
            {
                ipInfo.Country = null;
            }

            return(ipInfo.Country);
        }