Home >Backend Development >PHP Tutorial >PHP implements mobile phone location query API interface_PHP tutorial
This API has not been tested by this site. The webmaster will update it as soon as possible after testing it. stay tuned. Thank you for your support!
Mainly implemented using curl, you need to enable PHP's support for 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 ‘Mobile phone number format error!’;
} else {
echo $data;
}
}
?>