您的位置:首页 > 其它

腾讯的IP地址API接口地址

2013-06-06 16:44 330 查看
腾讯的IP地址API接口地址:http://fw.qq.com/ipaddress

返回的是数据格式为:var IPData = new Array(“114.218.183.139″,””,”江苏省”,”苏州市”);

使用JS代码进行调取:

查看源代码打印帮助

1
<script language=
"javascript"
type=
"text/javascript"
src=
"http://fw.qq.com/ipaddress"
></script>
2

3
<script>document.write(
"你的IP是:"
+IPData[0]+
",来自:"
+IPData[2]);</script>
使用PHP解析的方法:

查看源代码打印帮助

01
<?php

02
function
getIpPlace(){
03
$ip
=
file_get_contents
(
"http://fw.qq.com/ipaddress"
);
04
$ip
=
str_replace
(
'"'
,
'
'
,
$ip
);
05
$ip2
=
explode
(
"("
,
$ip
);
06
$a
=
substr
(
$ip2
[1],0,-2);
07
$b
=
explode
(
","
,
$a
);
08
return
$b
;
09
}

10
$ip
=getIpPlace();
11
print_r(
$ip
);
12
?>
处理后输出的是一个数组。

另:

新浪的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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: