从maxmind javascript中检索数据库


retrieve database from maxmind javascript

我试图通过maxmindjavascript检索国家代码,但返回null,为什么?**想要按国家代码获取时区。**

一旦我得到了国家代码,我就想把它改掉。我在这里得到了时区数据。但是javascript返回空

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>

您有http://j.maxmind.com/app/geoip.js作为500内部服务器错误返回给我。同样,你没有正确使用它,首先你需要在页面加载时有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);