当前位置:实例文章 » PHP实例» [文章]PHP实现手机归属地查询API接口实现代码

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

发布人:shili8 发布时间:2022-12-07 17:59 阅读次数:24

复制代码 代码如下:

<?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>

相关标签:

免责声明

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱290110527@qq.com删除。

其他信息

其他资源

Top