0

When I check the avability of a .de-domain with fsockopen it delivers always a result, but when do the same with cURL around 75% of the queries fail. curl_errno then delivers error-code 56 (CURLE_RECV_ERROR). When I try to check .com-domain with whois.crsnic.net then cURL works fine, everytime. Only whois.denic.de makes trouble.

Here's the code:

$domain = "google.de";
$whois_server = "whois.denic.de";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $whois_server.":43"); // Whois Server
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $domain."\r\n"); // Query
$whois = curl_exec ($ch);  

echo "RESULT: ".$whois;
echo "<br/>";
echo curl_errno ($ch);
echo "<br/>";

Here's the fsockopen query:

fsockopen($whois_server,43, $errno, $error, 5);

Has anyone an idea what could be wrong? Thanks!

Crayl
  • 1,883
  • 7
  • 27
  • 43

2 Answers2

3

whois.denic.de requires -T dn to be prepended before your request.

E.g.:

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "-T dn $domain\r\n"); // Query
Robert
  • 5,278
  • 43
  • 65
  • 115
0

Are you in linux or windows? If in linux just execute:

system('whois google.de');
Reza S
  • 9,480
  • 3
  • 54
  • 84
  • This is the worst advice to give. Do not escape to the shell from your program just to run a whois client. You have specific libraries in PHP to do whois queries or at the bottom of it just open a TCP socket to port 43. – Patrick Mevzek Jan 04 '18 at 14:54