问题描述
您知道给定IP地址的任何服务会返回位置/国家/地区的服务吗?我发现了一些可以添加到数据库中的列表,但是我需要经常更新吗?是否有任何规则(例如电话号码)知道原籍国?
Do you know of any service which given an ip address it returns a location/country?I found a few lists we can add to our database but do I need to update them often? Is there any rule (like telephone numbers) to know the country of origin?
对不起,我知道这听起来可能是一个愚蠢的问题,但对于我们正在做的事情,它不会失败.
Sorry, I know this might sound a stupid question but for what we're doing it can't fail.
我忘了提到它必须以编程方式(PHP)可访问
I forgot to mention this has to be accessible programmatically (PHP)
谢谢:)迪奥戈
推荐答案
查看以下内容: http://www.farhad.ca/2011/06/15/rbl-based-ip-to-location/
假设问题IP地址是10.11.12.13,那么这里是一个示例:
Assume IP address of question is 10.11.12.13, then here is a sample:
<?php
$ip_address = gethostbyname('13.12.11.10.rbloc.dayanadns.com');
list($d1,$d2,$d3,$d4) = explode('.',$ip_address);
$country_code = chr($d3).chr($d4);
print "Result address: ".$ip_address."\n";
print "Country code: ".$country_code."\n";
?>
这篇关于ip地址的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!