分享给大家一个携号转网和归属地查询接口,数据来自中国联通实时数据哦,非常准确
接口地址 https://love1314.xin/code/area/index.php?phone=13771942591
正确的返回
{
"pro": "江苏",
"city": "苏州",
"op": "中国移动",
"isxie": "正常"
}
附上HTML代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>携号转网和归属地查询</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
color: #333;
text-align: center;
padding: 20px;
}
h1 {
color: #4CAF50;
}
form {
margin: 20px auto;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
max-width: 400px;
}
input[type="text"] {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
#result {
margin: 20px auto;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
max-width: 400px;
}
</style>
</head>
<body>
<h1>携号转网和归属地查询</h1>
<form id="queryForm">
<label for="phoneNumber">手机号:</label>
<input type="text" id="phoneNumber" name="phoneNumber" required>
<button type="submit">查询</button>
</form>
<div id="result"></div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$('#queryForm').on('submit', function(event) {
event.preventDefault();
var phoneNumber = $('#phoneNumber').val();
$.ajax({
url: `https://love1314.xin/code/area/index.php?phone=${phoneNumber}`,
method: 'GET',
success: function(data) {
$('#result').html(`
<p><strong>省份:</strong> ${data.pro}</p>
<p><strong>城市:</strong> ${data.city}</p>
<p><strong>运营商:</strong> ${data.op}</p>
<p><strong>协转状态:</strong> ${data.isxie}</p>
`);
},
error: function(error) {
$('#result').html(`<p>查询失败: ${error.responseText}</p>`);
}
});
});
});
</script>
</body>
</html>