Pythorian

Get IP vitals in PHP

Sep 27th, 2012
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. <?php
  2. $ip = '';
  3. $ch = curl_init();
  4.    
  5.     curl_setopt($ch, CURLOPT_URL, 'http://whois.arin.net/rest/ip/' . $ip);
  6.     curl_setopt($ch, CURLOPT_HEADER, 0);
  7.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  8.     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
  9.    
  10.     $returnValue = curl_exec($ch);
  11.    
  12.     curl_close($ch);
  13.    
  14.     $result = json_decode($returnValue);
  15.     $rdns = gethostbyaddr($ip);
  16.  
  17. echo $rdns;
  18. echo $result->net->name->{'$'};
  19. echo $result->net->orgRef->{'@name'};
  20. ?>
  21.  
  22. Output:
  23. cpe-24-92-*-*.nycap.res.rr.com
  24. Name: ROAD-RUNNER-3
  25. OrgRef: Road Runner HoldCo LLC
Advertisement
Add Comment
Please, Sign In to add comment