又多了一个工具咯,这个是手机号码归属地查询,copy了代码试了试还真有效果呀。地址:手机号码归属地查询程序,下面又API调用代码。就是不怎么美观,改天修改好看点。哈哈!下面分享机号码归属地查询API。
首先创建index.html,代码如下:
<html>
<title>手机号码归属地查询 – 超人流水账</title>
<form action=“mobile.php” method=“get”>
手机号: <input type=“text” name=“number”/> <input type=“submit” value=“查询” />
</form>
</html>
<title>手机号码归属地查询 – 超人流水账</title>
<form action=“mobile.php” method=“get”>
手机号: <input type=“text” name=“number”/> <input type=“submit” value=“查询” />
</form>
</html>
index.html 页面用来支持 GET 方式提交到mobile.php,mobile.php代码如下:
<?php
header(“Content-Type:text/html;charset=utf-8″);
if (isset($_GET['number'])) {
$url = ‘http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo’;
$number = $_GET['number'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, “mobileCode={$number}&userId=”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
$data = simplexml_load_string($data);
if (strpos($data, ‘http://’)) {
echo ‘手机号码格式错误!’;
} else {
echo $data;
}
}
?>
header(“Content-Type:text/html;charset=utf-8″);
if (isset($_GET['number'])) {
$url = ‘http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo’;
$number = $_GET['number'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, “mobileCode={$number}&userId=”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
$data = simplexml_load_string($data);
if (strpos($data, ‘http://’)) {
echo ‘手机号码格式错误!’;
} else {
echo $data;
}
}
?>
把index.html跟mobile.php放在统一个文件夹里面,这样就搞定啦。最后欢迎前往:手机号码归属地查询程序
36 评论
添加评论