简体   繁体   中英

WHOIS query object

Ok....while learning web development every so often i get stuck, knowing that i'm missing a one little basic piece of information and just grinding to find out what. It happens because experienced programmers don't care about restating the basics.

Anyway, i am trying to retrieve information from a WHOIS server, namely whois.apnic.net. Now this query works fine and returns all 1528 bytes

<?php
$abc=fsockopen("whois.godaddy.com", 43);
$xyz="website.com";
fputs($abc,$xyz);
$output = fread($abc,1528);
print_r($output);
if(!$output)
{
echo "there is no output";
}
?>

But this one only returns the first two lines

<?php
$abc=fsockopen("whois.apnic.net", 43);
$xyz="194.6.248.10";
fputs($abc,$xyz);
$output = fread($abc,1528);
print_r($output);
if(!$output)
{
echo "there is no output";
}
?>

I have tried a lot of modifications in the code for example fgets instead of fread, url instead of ip address, when i put while(!feof($abc)) condition into the prior code it returns everything, but when i put this in the second code it just times out or keeps working if i remove the time limit. The above IP address is from Europe but the online Apnic WHOIS tool gives information about it and the WHOIS API documentation also states that Apnic can contact other Registries and retrieve info about any IP address.

The apnic website talks about sending and returning objects, just 'objects', no reference. I presumed its talking about XML objects. I just want a small, basic, simple example of how to query this API and get and output the 'objects'. Thanks!

您要查找的IP地址在RIPE(Whois.ripe.net)而不是APNIC管理的范围内。

    $whoisserver = 'whois.verisign-grs.com';
$domain = 'name.com';
$port = 43;
$timeout = 10;
$fp = @fsockopen($whoisserver, $port, $errno, $errstr, $timeout) or die("Socket Error " . $errno . " - " . $errstr);
fputs($fp, $domain . "\r\n");
while(!feof($fp)){
    $out .= fgets($fp);
}
fclose($fp);
  1. .com whois whois.verisign-grs.com
  2. .net whois whois.verisign-grs.com
  3. .org whois whois.pir.org
  4. etc.

The service url: http://akan.online/checkName.com happy saturday

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM