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>