PHP實(shí)現(xiàn)手機(jī)歸屬地查詢(xún)API接口實(shí)現(xiàn)代碼
更新時(shí)間:2012年08月27日 22:56:01 作者:
主要使用curl實(shí)現(xiàn),需要開(kāi)啟php對(duì)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ī)號(hào)碼格式錯(cuò)誤!';
} else {
echo $data;
}
}
?>
<form action=”mobile.php” method=”get”>
手機(jī)號(hào)碼: <input type=”text” name=”number” /> <input type=”submit” value=”提交” />
</form>
相關(guān)文章
php基于curl擴(kuò)展制作跨平臺(tái)的restfule 接口
這篇文章主要介紹了php基于curl擴(kuò)展制作跨平臺(tái)的restfule 接口的相關(guān)資料以及詳細(xì)的代碼,有需要的小伙伴可以參考下。2015-05-05ThinkPHP實(shí)現(xiàn)將本地文件打包成zip下載
這篇文章主要介紹了ThinkPHP實(shí)現(xiàn)將本地文件打包成zip下載的方法,需要的朋友可以參考下2014-06-06php+mysql實(shí)現(xiàn)簡(jiǎn)單登錄注冊(cè)修改密碼網(wǎng)頁(yè)
這篇文章主要為大家詳細(xì)介紹了php+mysql實(shí)現(xiàn)簡(jiǎn)單登錄注冊(cè)修改密碼系統(tǒng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-11-11PHP通用分頁(yè)類(lèi)page.php[仿google分頁(yè)]
PHP通用分頁(yè)類(lèi)。本代碼是用于分頁(yè)用的,稍做修改可用于各種程序。 使用方式請(qǐng)參考本人文章。2008-08-08