【问题标题】:retrieve database from maxmind javascript从 maxmind javascript 检索数据库
【发布时间】:2014-09-30 09:13:32
【问题描述】:

我正在尝试通过 maxmind 检索国家/地区代码 javascript 但返回 null 为什么? ** 想通过国家代码获取时区。**

一旦我得到国家代码,我就想实施它。我在这里得到了时区数据。但是javascript返回null

https://github.com/maxromanovsky/php-maxmind-geoip/blob/master/timezone/timezone.php

 <script src="http://j.maxmind.com/app/geoip.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script type="text/javascript">
    $("#country").html( 'Country: ' + geoip_country_code() );
    <?php $country = geoip_country_code(); ?>
    </script>
<div id="country"></div>

【问题讨论】:

    标签: javascript php maxmind


    【解决方案1】:

    您是否有 http://j.maxmind.com/app/geoip.js 的本地副本,因为 500 Internals 服务器错误返回给我。另外你没有正确使用这个,首先你需要在页面加载时有geoip_country_code();,如果这实际上是JS函数,我没有得到PHP部分,因为PHP MaxMind代码中没有这样的函数geoip_country_code() .在您的 php 中执行以下操作

    <?php
    include('geoip.inc');
    include('geoipregionvars.php');
    include('timezone/timezone.php');
    
    $gi = geoip_open(PATH_TO_GeoIP.dat,GEOIP_STANDARD);
    
    list($country_code,$region) = geoip_region_by_addr($gi, $IP_ADDRESS);
    $timeZone = get_time_zone($country_code,$region);
    

    【讨论】:

    • 我在ussage的条款和条件中发现如果你有免费用户,你可以限制maxmind的使用,Per ip 1 query。所以你返回 500 错误。我也返回 500 错误。我想测试一个网站,但 maxmind 每个 ip 只给我 1 个结果 ....
    • 按照github.com/maxromanovsky/php-maxmind-geoip的说明,下载免费的maxmind db,不需要他们的JS,可以用PHP开发自己的,没有限制。
    • 是的,我得到了 当我使用这个时,我得到了正确的结果,但是如何通过 ip 获得“IN”,“”??
    • 我使用:timezone/test_timezone.php
    • 我收到错误通知:使用未定义的常量 PATH_TO_GeoIP - 在第 9 行的 C:\xampp\htdocs\mas\timezone\test_timezone.php 中假设为 'PATH_TO_GeoIP' 注意:使用未定义的常量 dat - 假设第 9 行 C:\xampp\htdocs\mas\timezone\test_timezone.php 中的“dat”警告:fopen(PATH_TO_GeoIPdat):无法打开流:C:\xampp\htdocs\mas\timezone\ 中没有此类文件或目录第 386 行的 geoip.inc 无法打开 PATH_TO_GeoIPdat
    猜你喜欢
    • 1970-01-01
    • 2016-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-19
    相关资源
    最近更新 更多