IP地址/域名查询

1、使用
DEMO
2、查询说明

如果传入的数据是 IP 地址,那么直接返回 IP 地址对应的省(市/自治区)、市(区/自治州)、区(县/市/区)以及运营商名称;如果传入的数据是域名,则先解析出域名对应的 IP 地址,再返回 IP 地址对应的省(市/自治区)、市(区/自治州)、区(县/市/区)以及运营商名称。

3、接口使用
http://www.xapi.ltd/api/ip?uid=195&appkey=24be320a26da4712263b5d380946a116f77660ba&ip=113.104.214.231
http://www.xapi.ltd/api/ip?uid=195&appkey=24be320a26da4712263b5d380946a116f77660ba&ip=113.104.214.231

4、请求参数
参数 必须 类型 描述
uid string 用户UID点击查看
appkey string 用户页面的APPKEY点击查看
ip string 要搜索的IP或者域名
5、返回参数
{
	"status": 1,
	"result": {
		"address": "广东省 深圳市",
		"ip": "113.104.214.231",
		"isp": "中国电信"
	},
	"code": 0,
	"msg": "查询成功"
}
参数 必须 类型 描述
static int 接口响应结果:0失败;1成功
msg string 响应描述
code int 错误码,一般为0
result object 返回查询结果信息
6、代码示例
//接口地址
$api_url = "http://www.xapi.ltd";
//uid
$uid = "195";
//appkey
$appkey = "24be320a26da4712263b5d380946a116f77660ba";
//要搜索的IP地址/域名
$ip = "113.104.214.231";
$url = $api_url."/api/ip?uid=".$uid."&appkey=".$appkey."&ip=".$ip;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
//输出返回结果
$result = json_decode($result,true);
var_dump($result);
var api_url = "http://www.xpi.ltd";
var uid = "195";
var appkey = "24be320a26da4712263b5d380946a116f77660ba";
var ip = "113.104.214.231";
$.ajax({
	type:"post",
	url: api_url+"/api/ip",
	data: {"appkey":appkey,"uid":uid,"ip":ip},
	success: function(data){
		console.log(data);
	},
	error: function(){
		alert("网络错误~请稍后再试");
	},
	dataType: "json"	      		
});

0.008510s