溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

怎么在PHP中利用萬網(wǎng)的接口實現(xiàn)一個域名查詢功能

發(fā)布時間:2021-01-18 15:41:33 來源:億速云 閱讀:139 作者:Leah 欄目:開發(fā)技術(shù)

怎么在PHP中利用萬網(wǎng)的接口實現(xiàn)一個域名查詢功能?很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。

代碼如下:

<form name="form1" method="post" action="chaxun.php"> 

<tbody><tr>
<td align="right" valign="middle" width="251">
<p align="center">
<img border="0" src="./templates/img/www.gif"><input name="dns" type="text" id="dns" size="20" ></p></td>
<td  valign="top" width="99">
<!--
<input type="image" src="./templates/img/cx.gif" align="left" onclick="submit()" width="50" height="18">
-->
<input type="submit" value="查詢"/>
</td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" >
<table width="96%" border="0" cellspacing="0" cellpadding="0" height="94%">
<tbody><tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="com" checked="">.com</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="cn" checked="">.cn</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="tel" checked="">.tel</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="mobi">.mobi</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="net" checked="">.net</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="org">.org</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="asia">.asia</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="me">.me</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="com.cn" checked="">.com.cn</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="net.cn">.net.cn</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="org.cn">.org.cn</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="gov.cn">.gov.cn</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="hk">.hk</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="tv">.tv</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="biz">.biz</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="cc">.cc</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="name">.name</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="info">.info</td>
</tr>
<tr>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="公司">.公司</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="網(wǎng)絡(luò)">.網(wǎng)絡(luò)</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="中國">.中國</td>
</tr>
</tbody></table></td>
</tr>

</tbody>
</form>


PHP代碼:

復(fù)制代碼 代碼如下:


<?php

//得到頂級域名
$ext=$_POST['ext'];
//得到二級域名
$dns = $_POST['dns'];

//print_r($ext);
//$domain = $dns . "." . $ext[0];
//echo $domain;

//遍歷所有的域名
foreach ($ext as $value) {
//組合域名
$domain = $dns . "." . $value;

//查詢:
echo $domain ;

$do = "http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=" . $domain;
$xml_data = file_get_contents($do);
$result_arr = (array) simplexml_load_string($xml_data);

$returncode=$result_arr['returncode'];
$key=$result_arr['key'];

$original=$result_arr['original'];

$status= substr($original,0,3);

if($status=="210"){

echo ":恭喜您,可以注冊";

}else if($status=="211"){

echo ":已經(jīng)注冊";

}else if($status=="212"){

echo ":參數(shù)錯誤";

}
echo '<br>';

}

?>

看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進一步的了解或閱讀更多相關(guān)文章,請關(guān)注億速云行業(yè)資訊頻道,感謝您對億速云的支持。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

php
AI