Home >php教程 >php手册 >PHP实现手机归属地查询API接口

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

WBOY
WBOYOriginal
2016-06-13 10:51:261590browse

该API未经本站测试。站长测试之后会在第一时间更新。敬请关注。谢谢支持!
主要使用curl实现,需要开启php对curl的支持。
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;
}
}
?>


手机号码:

作者:啊和
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php上传文件详解Next article:php截取html文章