我想整合一個API與我的網站之一,這是我的高級給出的任務。API是關於搜索域名已經存在與否..請幫助我在這個問題上 請給我一個例子,我可以參考。我的網站是在PHP中。域註冊表api集成在php
0
A
回答
1
[編輯2]作爲@Poe提到了他的意見,gethostbyname可能是一個更好的解決方案,因爲它適用於任何頂級域名,因爲它執行DNS查詢,而不是使用whois查詢,也更易於實施和可能更快:
<?php
$ip = gethostbyname('example.com');
if (strstr($ip,"example.com")){
echo "No match for domain example.com<br />\n";
} else {
echo "Domain found. Query output: <br />\n".$ip;
}
?>
反正域名可以註冊,但它不與任何計算機(例如,雖然這是非常罕見的,你可能會得到www.example.com而不是例如分辨率。 com)
[編輯]我以前沒有發佈過這個消息,因爲我在連接到端口43上的whois.internic.net以執行whois查詢時遇到了一些問題(以爲他們已經關閉了該服務)。無論如何,這是一個基於fsockopen的解決方案,我認爲它比我在使用CGI web腳本之前給出的解決方案好得多,也更簡單。希望它可以幫助(用法:myqueryscript.php域= domainiwanttocheck.com?):
<?php
$fp = fsockopen("199.7.58.74", 43, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$query = $_GET['domain']."\r\n";
$answer= '';
fwrite($fp, $query);
while (!feof($fp)) {
$answer .= fgets($fp, 128)."<br />";
}
fclose($fp);
if (strstr($answer,"No match for")){
echo "No match for domain ".$_GET['domain']."<br />\n";
} else {
echo "Domain found. Query output: <br />\n".$answer;
}
}
?>
從InterNIC的網站,這是HTML代碼來實現的whois查詢:
<form method="get" action="http://reports.internic.net/cgi/whois" name="my_form">
<input type="text" size="30" name="whois_nic" maxlength="80">
<br>
<input type="radio" name="type" value="domain" checked>
Domain<font size="-1"> (ex. internic.net)
<br>
<input type="radio" name="type" value="registrar">
Registrar<font size="-1"> (ex. ABC Registrar, Inc.)
<br>
<input type="radio" name="type" value="nameserver">
Nameserver (ex. NS.EXAMPLE.COM or 192.16.0.192)<br>
<br>
<input type="submit" value="Submit">
</form>
這意味着你可以發送一個像這樣的whois查詢:http://reports.internic.net/cgi/whois?whois_nic=domainiwanttocheck.com&type=domain
您可以從腳本發送查詢並將響應存儲在DOMDocument對象上。檢出:http://www.php.net/manual/en/domdocument.loadhtml.php
如果您使用此方法查找域並且域不存在,您將得到字符串No match for domain
。使用strpos
如果該域存在的反應看這一點,您可以過濾響應包括有關注冊機構的信息等,這將是HTML標籤的響應<pre>
的內容:
<pre>
Whois Server Version 2.0
Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.
Domain Name: GOOGLE.COM
Registrar: MARKMONITOR INC.
Whois Server: whois.markmonitor.com
Referral URL: http://www.markmonitor.com
Name Server: NS1.GOOGLE.COM
Name Server: NS2.GOOGLE.COM
Name Server: NS3.GOOGLE.COM
Name Server: NS4.GOOGLE.COM
Status: clientDeleteProhibited
Status: clientTransferProhibited
Status: clientUpdateProhibited
Status: serverDeleteProhibited
Status: serverTransferProhibited
Status: serverUpdateProhibited
Updated Date: 20-jul-2011
Creation Date: 15-sep-1997
Expiration Date: 14-sep-2020
>>> Last update of whois database: Sat, 25 Aug 2012 10:15:09 UTC <<<
NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar. Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.
TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability. VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.
The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.
</pre>
另外,看看這個相關的問題:Who provides a WHOIS API?
相關問題
- 1. 域名註冊API
- 2. facebook註冊表集成
- 3. 課堂API - 跨域註冊
- 4. 如何將Mailerlite API集成到我的註冊表單上?
- 5. AJAX Mailchimp註冊表單集成
- 6. WSO2註冊表和Apache Synapse集成
- 7. CakePHP高度集成註冊表格
- 8. 在註冊區域
- 9. 域名註冊列表
- 10. 註冊/註冊表單PHP SQL
- 11. PHP註冊表 - SQL
- 12. 如何在註冊時在php中集成otp驗證
- 13. 如何通過ressellerclub API註冊域名
- 14. 用於註冊免費域的API
- 15. 域名註冊
- 16. WSO2 - 治理註冊表API
- 17. 在PHP中集成SOAP API
- 18. 如何生成註冊號。在PHP中?
- 19. 在ipad上的WHMCS API中爲域註冊提供的TLD /註冊期無效
- 20. WSO2治理註冊表無法通過註冊表API
- 21. PHP icontact API集成
- 22. Paypal PHP API集成
- 23. Soundcloud API PHP集成
- 24. Securesocial註冊註冊的其他領域
- 25. PHP腳本的域名註冊
- 26. SIP註冊API
- 27. Facebook API註冊
- 28. php註冊表問題
- 29. 用PHP註冊表格
- 30. php mysql註冊表格
最好不要使用過時的''元素! – ComFreek
ohh ..非常感謝你,我現在有點關於api集成的想法..可以請你解釋一些重要的事情,比如它是如何工作的,什麼是功能,什麼是代碼使用這個api這樣的..所以我可以修改它,並學習一些東西 –
我更新了我的問題,包括一些關於如何從PHP腳本進行查詢並將響應存儲在DOMDocument對象上的提示。關於API,它有很好的文檔記錄。閱讀有關如何在此處使用它的信息:http://www.whoisxmlapi.com/whois-api-doc.php – NotGaeL