新浪IP归属地API

1

之前用过腾讯的AIP,但是官方暂停这个服务了,新浪的API时间很久了,稳定性也很好,但愿能一劳永逸。

PHP代码

<?php
$ip = "218.192.3.42";
$json = file_get_contents("http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=".$ip);
$json = json_decode($json, true);
echo "IP地址:".$ip;
echo "归属地:".$json["country"].$json["province"].$json["city"].$json["district"].$json["isp"];
?>

JS代码

<script type="text/javascript" src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js" charset="utf-8"></script>
<script type="text/javascript">
alert(remote_ip_info.country+" "+remote_ip_info.city);
</script>

共 1 条评论

  1. 回复

    不错,非常有用

发表评论

您的邮箱不会公开,当您的评论有新的回复时,会通过您填写的邮箱向您发送评论内容。 必填字段 *

为何看不到我发布的评论?

正在提交, 请稍候...