使用 API 访问者的 IP 来显示他们的标志
Using IP of visitors with API for displaying Flags of them
我在下面写了 PHP 获取访问者 IP 的代码,并使用 API 显示访问者所在国家/地区的国旗。此代码适用于我的主机,但 2 个月后我突然发现它没有显示访问者的标志!我真的不知道发生了什么事!有知道的请指导一下,万分感谢
<?php
$ip=$_SERVER['REMOTE_ADDR'];
$json_data = file_get_contents("http://ip-api.com/json/$ip");
$ip_data = json_decode($json_data, TRUE);
if ($ip_data['status'] == 'success') {
?>
<?php }
?>
<?php
$country= $ip_data['countryCode'];
echo "<img src='http://b-c-e.us/country/images/$country.png' height='13' width='20'/>";
?>
难道是这个(摘自http://ip-api.com/docs/)
Usage limits Our system will automatically ban any IP addresses doing
over 150 requests per minute. To unban your IP click here.
You are free to use ip-api.com for non-commercial use. We do not allow
commercial use without prior approval.
For commercial, unlimited use see our pro service.
也在http://b-c-e.us/country/images/
有些图片似乎是 .jpg,因此您可能希望在代码中覆盖它。
我在下面写了 PHP 获取访问者 IP 的代码,并使用 API 显示访问者所在国家/地区的国旗。此代码适用于我的主机,但 2 个月后我突然发现它没有显示访问者的标志!我真的不知道发生了什么事!有知道的请指导一下,万分感谢
<?php
$ip=$_SERVER['REMOTE_ADDR'];
$json_data = file_get_contents("http://ip-api.com/json/$ip");
$ip_data = json_decode($json_data, TRUE);
if ($ip_data['status'] == 'success') {
?>
<?php }
?>
<?php
$country= $ip_data['countryCode'];
echo "<img src='http://b-c-e.us/country/images/$country.png' height='13' width='20'/>";
?>
难道是这个(摘自http://ip-api.com/docs/)
Usage limits Our system will automatically ban any IP addresses doing over 150 requests per minute. To unban your IP click here.
You are free to use ip-api.com for non-commercial use. We do not allow commercial use without prior approval.
For commercial, unlimited use see our pro service.
也在http://b-c-e.us/country/images/
有些图片似乎是 .jpg,因此您可能希望在代码中覆盖它。