您的位置:首页 > 其它

调用新浪接口获得访问者地理位置及线路情况

2013-05-15 16:01 232 查看
新浪的IP地址查询接口:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js

新浪多地域测试方法:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=218.192.3.42

搜狐IP地址查询接口(默认GBK):http://pv.sohu.com/cityjson

搜狐IP地址查询接口(可设置编码):http://pv.sohu.com/cityjson?ie=utf-8

搜狐另外的IP地址查询接口:http://txt.go.sohu.com/ip/soip

腾讯的接口:http://fw.qq.com/ipaddress (腾讯的接口原本是最好用的,可现在打不开啦)

直接访问新浪接口的php文件会返回如下内容:

var remote_ip_info = {"ret":1,"start":"58.58.32.0","end":"58.58.47.255","country":"\u4e2d\u56fd","province":"\u5c71\u4e1c","city":"\u9752\u5c9b","district":"","isp":"\u7535\u4fe1","type":"","desc":""};

这是这是encode后的json串,decode后内容:

{

"ret":1,

"start":"58.58.32.0",

"end":"58.58.47.255",

"country":"中国",

"province":"山东",

"city":"青岛",

"district":"",

"isp":"电信",

"type":"",

"desc":""

}

新浪js接口使用举例:

<script type="text/javascript" src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js" charset="gb2312"></script>

<script type="text/javascript">

var ss = remote_ip_info['country'] + remote_ip_info['province']+ remote_ip_info['city'];

alert(ss)

</script>

参考原文:http://blog.sina.com.cn/s/blog_69d6a78101011ksf.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: