PHP实现手机归属地查询API接口实现代码

前端之家收集整理的这篇文章主要介绍了PHP实现手机归属地查询API接口实现代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<div class="codetitle"><a style="CURSOR: pointer" data="65359" class="copybut" id="copybut65359" onclick="doCopy('code65359')"> 代码如下:

<div class="codebody" id="code65359">
<?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;
}
}
?>

手机号码:

猜你在找的PHP相关文章