0xspade

My API Usage

Jan 17th, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. <?
  2.     //this is an example for fetching my API
  3.     // so excited to publish it to public
  4.     // ~: Spade was here :~ //
  5.     $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : $_SERVER['HTTP_CLIENT_IP'];
  6.     $link = "http://site.com/api.php?ip=".filter_var($ip, FILTER_VALIDATE_IP);//this is perfect for validating IP Address filter_shit
  7.     $curl = curl_init();
  8.     curl_setopt($curl, CURLOPT_URL, $link);
  9.     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  10.     $results = curl_exec($curl);
  11.     curl_close($curl);
  12.  
  13.     foreach(json_decode($results) as $result => $res){
  14.         echo "~ " .$result. " :: ".$res."\r\n";
  15.     }
  16.  
  17.     // You can also use the below method
  18.     /*
  19.         // {"ip":"66.85.139.244","hostname":"node244.dualstartnetworks.com","city":"Phoenix, Arizona","zip":"85001","country":"United States","countryCode":"US","location":"33.4484,-112.074","timezone":"-07:00","vpn_user":"yes"} // this is just an example of my API shit.
  20.         $res = json_decode($results, true);
  21.         echo "IP: ".$res['ip']."\r\n";
  22.         echo "Hostname: ".$res['hostname']."\r\n";
  23.         echo "City: ".$res['city']."\r\n";
  24.         echo "Zip Code: ".$res['zip']."\r\n";
  25.         echo "Country: ".$res['country']."\r\n";
  26.         echo "Country Code: ".$res['countryCode']."\r\n";
  27.         echo "Location[lat/long]: "$res['location']."\r\n";
  28.         echo "Time Zone: ".$res['timezone']."\r\n";
  29.         echo "VPN User?: ".$res['vpn_user']."\r\n"; //this is my favorite part here, my API can track if he's/she's using an Proxy/VPN
  30.     */
  31. ?>
Add Comment
Please, Sign In to add comment