duanqie8549 2011-12-19 03:22
浏览 21
已采纳

获取网站访问者位置的最佳方式是什么? [关闭]

After googling, I found many solutions that don't seem to work or require permission from the user.

Looking for something that is easy to use, PHP or Javascript, and does not require the user's permission. It doesn't need to be the most accurate.

  • 写回答

3条回答 默认 最新

  • dongmei9508 2011-12-19 03:30
    关注

    Google Analytics is great for this (javascript).

    EDIT: Should point out that Google Analytics has an API to get City/Country info and all reporting info if you need to programmatically do something with it - http://code.google.com/apis/analytics/docs/

    But if that's not an option:

    You can get a users ip with PHP's $_SERVER['REMOTE_ADDR']

    With that, you can use PHP's GeoIP library to geolocate it: http://php.net/manual/en/book.geoip.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)