Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C在Unity 3d中获取IP地址#_C#_Html_Json_Ip_Unity3d - Fatal编程技术网

C# 使用C在Unity 3d中获取IP地址#

C# 使用C在Unity 3d中获取IP地址#,c#,html,json,ip,unity3d,C#,Html,Json,Ip,Unity3d,我想了解客户端ip的所有详细信息,如位置、地址、州、城市、国家、速度、isp等,就像这些家伙在做什么一样 我希望得到一个理想的Json或XMl响应,这样我就不必解析HTML了。目前我正在解析html myIP = myExtIPWWW.text; myIP=myIP.Substring(myIP.IndexOf("Your IP address is:"),myIP.IndexOf("</h3>")); myIP=myIP.Substring(myIP.IndexOf(":")+1

我想了解客户端ip的所有详细信息,如位置、地址、州、城市、国家、速度、isp等,就像这些家伙在做什么一样

我希望得到一个理想的Json或XMl响应,这样我就不必解析HTML了。目前我正在解析html

myIP = myExtIPWWW.text;
myIP=myIP.Substring(myIP.IndexOf("Your IP address is:"),myIP.IndexOf("</h3>"));
myIP=myIP.Substring(myIP.IndexOf(":")+1);
myIP=myIP.Substring(0,myIP.IndexOf("<"));
myIP=myExtIPWWW.text;
myIP=myIP.Substring(myIP.IndexOf(“您的IP地址是:”),myIP.IndexOf(“”);
myIP=myIP.Substring(myIP.IndexOf(“:”)+1);

myIP=myIP.Substring(0,myIP.IndexOf(“有免费数据库以(大)平面文件或数据库格式向您提供此信息。例如

但是,您应该知道,这些细节中没有一个是准确的(除了国家/地区)。如果您试图依赖它们做任何事情,那么您应该重新考虑您的策略,IP无法可靠地“定位”“这些数据库的工作通常基于将IP分配给各个ISP及其本地办事处和/或其所在的交易所的成熟IP。充其量,您将使用离您的用户最近的交易所

当然,如果用户实际拥有自己的ISP/IP,这不适用,因为他们可以将这些详细信息作为任何信息提供给您,而这就是您的数据库中的内容


为了举例说明这些细节是如何错误的,您在上面引用的网站向我提供了以下细节:

My IP address state:     London, City of
My IP address city:  London
My IP address latitude:  51.5142
My IP address longitude:     -0.0931
My ISP [?]:  VAIONI Group Ltd
我在曼彻斯特,Vaoni是经销商/连接端点,而不是我的ADSL提供商

我想获得客户的所有详细信息,如位置、地点、州、城市、国家、速度等

然后不要使用IP地址(因为我可能错过了最新的更新,但AFAIK IP地址不包含速度部分),但应使用以下适当的IP地址:

  iPhoneSettings.StartLocationServiceUpdates();
  print("Location: " + iPhoneInput.lastLocation.latitude + " " + 
                       iPhoneInput.lastLocation.longitude + " " + 
                       iPhoneInput.lastLocation.altitude + " " + 
                       iPhoneInput.lastLocation.horizontalAccuracy + " " + 
                       iPhoneInput.lastLocation.timestamp);

谢谢你的及时回复。你认为什么是最好的方式?这取决于你想做什么?但“最好的方式”是根本不做,除非你只是想得到这个国家,否则根本不可能,在这种情况下,你可以依靠他们95%的支持率(编造出来的,但似乎可行!)准确度。事实上,这是一个谎言。Windows本身现在提供了一个地理定位API(很像浏览器、移动设备等),它将解决一些因素,如GPS塔、IP等。当然,这在任何方面都不是100%准确度。我的浏览器的地理位置让我在萨尔福德,我离那里25英里。(当然,假设您使用Windows,如果您可以使用移动设备的地理位置,那么它们通常都有GPS,在这种情况下,它将是准确的!)unity标签是针对Microsoft unity的。不要误用它。