domaincheck(TLD) 通过 PHP API 可以获得什么
domaincheck(TLD) what is available via PHP API
我正在构建域检查,现在可以使用了。如果我测试例如 example.com 它说 example.com 是可用的是 不 可用。
但如果它不可用,我希望我的代码检查其他代码(如 example.org、example.nl、example.net、example.info 等)以查看如果这些可用或不可用。
这是我的校验码
unset($command);
$command = array(
"command" => "DomainsCheckAvailability",
"domain" => htmlentities($_POST['domain']),
"tld" => htmlentities($_POST['tld'])
);
$api = new Versio_api();
$versio = $api->api_send( $command );
IF($versio['success']==0) {
echo("Fout opgetreden. Fout code: ".$versio['command_response_code'].". Fout text: ".$versio['command_response_message']."");
}
else
{
IF($versio['status']==1) {
echo "<div class='wrapper'>";
echo "<div class='beschikbaar'>";
echo $_POST['domain'].$_POST['tld']. "";
echo " is available.";
echo "</div'>";
echo "</div'>";
}
else
{
echo "<div class='wrapper'>";
echo "<div class='beschikbaar'>";
echo $_POST['domain'].$_POST['tld']. "";
echo " is not available.";
echo "</div'>";
echo "</div'>";
};
};
这些是我的输入字段:
<form action="domeincheck.php" method="post">
<input class="www" type="text" value="www." /></input>
<input class="invul" placeholder="uw websitenaam" type="text" name="domain"></input>
<select id="dropdownveld" name="tld">
<option value=".nl">.nl</option>
<option value=".com">.com</option>
<option value=".net">.net</option>
<option value=".be">.be</option>
<option value=".eu">.eu</option>
<option value=".org">.org</option>
<option value=".biz">.biz</option>
<option value=".info">.info</option>
</select>
<button class="btn_submit" type="submit" name="SubMit" class="input">Controleren</button>
</form>
希望能帮到你!
想必您有执行检查的函数?我假设这叫做 domainAvailable()
。您需要做的就是创建一个要检查的 TLD 数组,然后遍历它们,将其添加到您要检查的域名的末尾,然后检查每个 TLD:
function domainAvailable($domain, $tld) {
$command = array(
"command" => "DomainsCheckAvailability",
"domain" => $domain,
"tld" => $tld
);
if ( $tld[0] == '.') {
$tld = substr($tld, 1);
}
$api = new Versio_api();
$res = $api->api_send( $command );
if ( $res['success'] )
return $res['status'] == 1;
return false;
}
$first_tld = $_POST['tld'];
$domain = $_POST['domain'];
if ( !domainAvailable($domain, $first_tld) ) {
echo '<br/>Domain '.htmlentities($domain.'.'.$first_tld).' is not available.<br/>What about these?<br/>';
$tlds = array('nl', 'com', 'net', 'be', 'eu', 'org', 'biz', 'info');
foreach($tlds as $tld) {
# Skip the first tld that was checked
if ( $tld != $first_tld) {
if ( domainAvailable($domain, $tld) )
echo '<br>'.htmlentities($domain).$tld.' is available';
else
echo '<br>'.htmlentities($domain).$tld.' is not available';
}
}
}
else {
echo '<br/>Domain '.htmlentities($domain.'.'.$first_tld).' is available';
}
更新: 我已经根据您更新的代码示例创建了一个 domainAvailable()
函数。
更新 2: 我稍微更改了代码。如果您可以正确使用 domainAvailable()
函数,它应该可以工作,我已经根据 API 文档和您发布的代码做出了最好的猜测。
您在这段代码中设置了 TLD:
$command = array(
[...]
"tld" => htmlentities($_POST['tld'])
);
在本例中,它来自 $_POST。如果您创建一个包含所有要检查的 TLD 的数组,请创建一个循环,将它们作为 "tld" 放入 $command 并执行
$api->api_send( $command );
您将收到每个 TLD 的回复。
我正在构建域检查,现在可以使用了。如果我测试例如 example.com 它说 example.com 是可用的是 不 可用。
但如果它不可用,我希望我的代码检查其他代码(如 example.org、example.nl、example.net、example.info 等)以查看如果这些可用或不可用。
这是我的校验码
unset($command);
$command = array(
"command" => "DomainsCheckAvailability",
"domain" => htmlentities($_POST['domain']),
"tld" => htmlentities($_POST['tld'])
);
$api = new Versio_api();
$versio = $api->api_send( $command );
IF($versio['success']==0) {
echo("Fout opgetreden. Fout code: ".$versio['command_response_code'].". Fout text: ".$versio['command_response_message']."");
}
else
{
IF($versio['status']==1) {
echo "<div class='wrapper'>";
echo "<div class='beschikbaar'>";
echo $_POST['domain'].$_POST['tld']. "";
echo " is available.";
echo "</div'>";
echo "</div'>";
}
else
{
echo "<div class='wrapper'>";
echo "<div class='beschikbaar'>";
echo $_POST['domain'].$_POST['tld']. "";
echo " is not available.";
echo "</div'>";
echo "</div'>";
};
};
这些是我的输入字段:
<form action="domeincheck.php" method="post">
<input class="www" type="text" value="www." /></input>
<input class="invul" placeholder="uw websitenaam" type="text" name="domain"></input>
<select id="dropdownveld" name="tld">
<option value=".nl">.nl</option>
<option value=".com">.com</option>
<option value=".net">.net</option>
<option value=".be">.be</option>
<option value=".eu">.eu</option>
<option value=".org">.org</option>
<option value=".biz">.biz</option>
<option value=".info">.info</option>
</select>
<button class="btn_submit" type="submit" name="SubMit" class="input">Controleren</button>
</form>
希望能帮到你!
想必您有执行检查的函数?我假设这叫做 domainAvailable()
。您需要做的就是创建一个要检查的 TLD 数组,然后遍历它们,将其添加到您要检查的域名的末尾,然后检查每个 TLD:
function domainAvailable($domain, $tld) {
$command = array(
"command" => "DomainsCheckAvailability",
"domain" => $domain,
"tld" => $tld
);
if ( $tld[0] == '.') {
$tld = substr($tld, 1);
}
$api = new Versio_api();
$res = $api->api_send( $command );
if ( $res['success'] )
return $res['status'] == 1;
return false;
}
$first_tld = $_POST['tld'];
$domain = $_POST['domain'];
if ( !domainAvailable($domain, $first_tld) ) {
echo '<br/>Domain '.htmlentities($domain.'.'.$first_tld).' is not available.<br/>What about these?<br/>';
$tlds = array('nl', 'com', 'net', 'be', 'eu', 'org', 'biz', 'info');
foreach($tlds as $tld) {
# Skip the first tld that was checked
if ( $tld != $first_tld) {
if ( domainAvailable($domain, $tld) )
echo '<br>'.htmlentities($domain).$tld.' is available';
else
echo '<br>'.htmlentities($domain).$tld.' is not available';
}
}
}
else {
echo '<br/>Domain '.htmlentities($domain.'.'.$first_tld).' is available';
}
更新: 我已经根据您更新的代码示例创建了一个 domainAvailable()
函数。
更新 2: 我稍微更改了代码。如果您可以正确使用 domainAvailable()
函数,它应该可以工作,我已经根据 API 文档和您发布的代码做出了最好的猜测。
您在这段代码中设置了 TLD:
$command = array(
[...]
"tld" => htmlentities($_POST['tld'])
);
在本例中,它来自 $_POST。如果您创建一个包含所有要检查的 TLD 的数组,请创建一个循环,将它们作为 "tld" 放入 $command 并执行
$api->api_send( $command );
您将收到每个 TLD 的回复。