Created
August 30, 2012 15:37
-
-
Save cam-gists/3531150 to your computer and use it in GitHub Desktop.
PHP: Quova / Neustar API IP Intel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Quova : http://developer.quova.com/ | |
| * * | |
| * Key Rate Limits | |
| * 2 Calls per second | |
| * 1,000 Calls per day | |
| */ | |
| // initiate curl and set options | |
| $ipin = '174.79.250.40'; // $_SERVER['REMOTE_ADDR']; | |
| $ch = curl_init(); | |
| $ver = 'v1/'; | |
| $method = 'ipinfo/'; | |
| $apikey = 'xxx'; | |
| $secret = 'xxx'; | |
| $timestamp = gmdate('U'); // 1200603038 | |
| // echo $timestamp; | |
| $sig = md5($apikey . $secret . $timestamp); | |
| $service = 'http://api.quova.com/'; | |
| curl_setopt($ch, CURLOPT_URL, $service . $ver. $method. $ipin . '?apikey=' . | |
| $apikey . '&sig='.$sig . '&format=json'); | |
| curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
| $data = curl_exec($ch); | |
| $headers = curl_getinfo($ch); | |
| // close curl | |
| curl_close($ch); | |
| // return XML data | |
| if ($headers['http_code'] != '200') { | |
| echo "An error has occurred accessing this IP"; | |
| return false; | |
| } else { | |
| echo '<pre>'.$data; | |
| return($data); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment