0

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!

Badarse
  • 47
  • 2
  • 9

2 Answers2

0

The IP address you want to lookup is in a range managed by RIPE (Whois.ripe.net) not APNIC.

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
  • Thanks for the hint, but Apnic says its WHOIS can handle all addresses. Still i would try out a different address later. Currently i'm behind a firewall that's blocking port 43. So if anyone could run the code with an Asian IP i would say thanks... – Badarse May 21 '12 at 16:43
0
    $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