收藏一个查询手机归属地API方便找......

接口数据比较老..除了号码套餐类型会出错.....归属地和运营商还是正确的....

============================我是可爱的分割线====================================

主要使用curl实现,需要开启php对curl的支持。
<?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;
}
}
?>
<form
action=”mobile.php” method=”get”>
手机号码: <input type=”text”
name=”number” /> <input type=”submit” value=”提交”
/>
</form>

=======================================我是可爱的分割线=======================================

 

再收藏一个方法:局域网内访问apache服务器的时候,服务器只需要修改http.ini的servername改成服务器IP地址就可以了....

posted on 2012-08-27 23:57  J.L_  阅读(168)  评论(0)    收藏  举报

导航