PHP--用万网的接口实现域名查询功能
网络编程 2021-07-05 09:49www.168986.cn编程入门
PHP用万网的接口实现域名查询功能,需要的朋友可以了解下
今天给别人做网站时有个需求是要有域名查询功能,查了点资料写了个简单的查询功能
前台页面用的是checkbox,代码如下
<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/.gif"><input name="dns" type="text" id="dns" size="20" style="background-color: #C0C0C0"></p></td>
<td style="padding-:11px;" valign="" 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="" style="padding-left:12px;">
<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="" checked="">.</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="" checked="">.</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="" checked="">.</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="">.</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="." checked="">..</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=".">..</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="gov.">.gov.</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="">.</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="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="网络">.网络</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="中国">.中国</td>
</tr>
</tbody></table></td>
</tr>
</tbody>
</form>
PHP代码
<?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.../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 "已经注册";
}else if($status=="212"){
echo "参数错误";
}
echo '<br>';
}
?>
前台页面用的是checkbox,代码如下
代码如下:
<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/.gif"><input name="dns" type="text" id="dns" size="20" style="background-color: #C0C0C0"></p></td>
<td style="padding-:11px;" valign="" 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="" style="padding-left:12px;">
<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="" checked="">.</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="" checked="">.</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="" checked="">.</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="">.</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="." checked="">..</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=".">..</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="gov.">.gov.</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="">.</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="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="网络">.网络</td>
<td align="left" width="76"><input name="ext[]" type="checkbox" id="ext" value="中国">.中国</td>
</tr>
</tbody></table></td>
</tr>
</tbody>
</form>
PHP代码
代码如下:
<?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.../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 "已经注册";
}else if($status=="212"){
echo "参数错误";
}
echo '<br>';
}
?>
编程语言
- 宿迁百度关键词排名指南:实现精准营销的关键
- 四川SEO优化怎么做网络推广
- 立昂技术备案老域名收购:如何为您的业务赋能
- 安徽百度关键词seo贵不贵,一般需要多少钱
- 吉林百度快照排名怎么做电话营销
- 多伦新手做SEO怎么做
- 甘肃优化关键词排名推广怎么做论坛营销
- 沙雅SEO网站推广:提升您的在线可见性
- 四川SEO优化如何提升销售额和销售量
- 聂荣网站排名优化:提升网站可见性的全方位指
- 涞水SEO:提升地方企业在线可见性的策略
- 辽宁百度seo排名怎样做网站排名
- 临湘哪有关键词排名优化:提升网站可见度的关
- 黑龙江百度网站优化有没有优惠
- 凉城优化关键词排名推广:提升您的网络可见性
- 萝北整站优化:提升您网站流量和排名的全面指