🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / C# / nerede olduğumu bulur ip ile

1-) C# -

public static string GetUserCountryByIp(string ip)

{

IpInfo ipInfo = new IpInfo();

try

{

string info = new WebClient().DownloadString("http://ipinfo.io/" + ip);

ipInfo = JsonConvert.DeserializeObject<IpInfo>(info);

RegionInfo myRI1 = new RegionInfo(ipInfo.Country);

ipInfo.Country = myRI1.EnglishName;

}

catch (Exception)

{

ipInfo.Country = null;

}

 

return ipInfo.Country;

}

public class IpInfo

{

[JsonProperty("ip")]

public string Ip { get; set; }

 

[JsonProperty("hostname")]

public string Hostname { get; set; }

 

[JsonProperty("city")]

public string City { get; set; }

 

[JsonProperty("region")]

public string Region { get; set; }

 

[JsonProperty("country")]

public string Country { get; set; }

 

[JsonProperty("loc")]

public string Loc { get; set; }

 

[JsonProperty("org")]

public string Org { get; set; }

 

[JsonProperty("postal")]

public string Postal { get; set; }

}

 

 2021 Ocak 18 Pazartesi
 530