查找用户位置(请帮我修复以下内容或建议其他任何方式)

时间:2014-11-15 18:39:07

标签: coldfusion ip-geolocation userlocation showuserlocation

希望有人可以帮我解决这个问题。我正在尝试实现一个全球网站,因此正在寻找一种方法来检测用户位置。我不想使用任何ip2location webservice或下载数据库或要求用户“共享位置”。

无论如何,我找到了这个项目。我实现了它,它正确地检测了我的位置(美国)。但是对于我在德国的朋友,它正在为Country返回一个空字符串。

http://javainetlocator.sourceforge.net/。我在这里使用jar文件。

我正在使用CF 11,我的代码在

http://roomdu.com/geolocator/

请建议我

1 个答案:

答案 0 :(得分:3)

某些德语IP不在InetAddressLocator提供的IP数据库中。您可以通过命令行以交互模式运行它来查看。

  

Codemans-MacBook:ColdFusionMX-geoLocator-2.23 Codeman $ java -jar InetAddressLocator.jar

  InetAddressLocator - Java country lookup.
  -----------------------------------------
  Copyright (C) 2003-05 Nigel Wetters Gourlay and Paul Hastings
  InetAddressLocator comes with ABSOLUTELY NO WARRANTY.
  This is free software, and you are welcome to redistribute
  it under the GNU General Public License.

  Running benchmark. Please be patient...
    Speed: 1260307 ops/sec
           (61% of address space is allocated)

  Locating localhost
    Host: /192.168.15.238
    Country: Unknown (private network)

  enter host ('q' to quit) > 5.199.139.54
    Host: /5.199.139.54
    Country: Unknown