Home  >  Article  >  Backend Development  >  php whois query API production method

php whois query API production method

高洛峰
高洛峰Original
2016-11-30 09:49:121829browse

Here we get the data from the data interface of Wanwang or Xinwang, and then output it through simple text processing in PHP.
Copy the code The code is as follows:
$domain = $_GET['q'];
preg_match("|

(.+?)|is", @file_get_contents('http://www.php.cn/Modules/agent/serv/pages/domain_whois.jsp?domainNameWhois='.$domain.'&noCode=noCode'), $whois);
echo $whois[1];
?>

After reaching this point, some friends may ask, isn’t this just a simple php script? ! Which is the api interface? Then let’s process it to make the query method more professional:
The query format we need is as follows:
http://api/whois/baidu.com
where baidu.com is the domain name that needs to be queried
You can modify the nginx configuration to achieve this:
Copy code The code is as follows:
location ~* /whois/(.+)$ {
proxy_pass http://127.0.0.1:8080/whois/index.php?q=baidu .com
# Pass the query to the apache of the intranet for processing
}

ok. Now a whois api interface is completed. You can call it in your own program or share it with everyone ^_^!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn