PHP實現(xiàn)手機(jī)歸屬地查詢API接口實現(xiàn)代碼
更新時間:2012年08月27日 22:56:01 作者:
主要使用curl實現(xiàn),需要開啟php對curl的支持
復(fù)制代碼 代碼如下:
<?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 ‘手機(jī)號碼格式錯誤!';
} else {
echo $data;
}
}
?>
<form action=”mobile.php” method=”get”>
手機(jī)號碼: <input type=”text” name=”number” /> <input type=”submit” value=”提交” />
</form>
相關(guān)文章
php基于curl擴(kuò)展制作跨平臺的restfule 接口
這篇文章主要介紹了php基于curl擴(kuò)展制作跨平臺的restfule 接口的相關(guān)資料以及詳細(xì)的代碼,有需要的小伙伴可以參考下。2015-05-05php+mysql實現(xiàn)簡單登錄注冊修改密碼網(wǎng)頁
這篇文章主要為大家詳細(xì)介紹了php+mysql實現(xiàn)簡單登錄注冊修改密碼系統(tǒng),具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-11-11