IP详细信息查询
详细地址包括城市经纬度

接口地址: https://www.58.linkpc.net/api/ipxx

返回格式: 请看返回示例

请求方式: GET

请求示例: https://www.58.linkpc.net/api/ipxx?ip=36.111.200.2

请求参数说明:

名称 必填 类型 说明
IP string 要查询的IP地址

返回参数说明:

名称 类型 说明

返回示例:

{"code":"0","msg":"success","data":{"continentCN":"亚洲","countryCN":"中国","zoneCN":"华中","provinceCN":"湖南","cityCN":"长沙","countyCN":"*","townCN":"*","ispCN":"电信","continentID":1,"countryID":48,"zoneID":4,"provinceID":27,"cityID":27001,"countyID":0,"ispID":26,"townID":0,"latitude":"28.211238","longitude":"112.967240","overseasRegion":false}}

错误码格式说明:

名称 类型 说明

代码示例:

<?php
header('Content-type: application/json; charset=utf-8');
date_default_timezone_set('PRC');
$url = 'https://58.linkpc.net/api/ipxx';
$type = isset($_GET['type']) ? $_GET['type'] : '';
if ($type == 'json' || $type == 'JSON') {
$result = file_get_contents($url . '?type=json');
echo $result;
} else {
// 使用cURL获取URL内容
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

// 检查内容类型并输出相应内容
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch);

if (strpos($contentType, 'image') !== false) {
// 输出图片
header('Content-Type: ' . $contentType);
echo $response;
} elseif (strpos($contentType, 'text') !== false) {
// 输出文字
header('Content-Type: ' . $contentType);
echo $response;
} elseif (strpos($contentType, 'application/json') !== false) {
// 输出JSON
header('Content-Type: application/json');
echo $response;
} else {
// 输出网页返回内容
header('Content-Type: text/html');
echo $response;
}
}
?>