0xspade icon

My API Usage

0xspade | PRO | 01/17/17 12:59:11 PM UTC | 0 ⭐ | 503 👁️ | Never ⏰ | []
PHP |

1.42 KB

|

None

|

0 👍

/

0 👎

<?
    //this is an example for fetching my API
    // so excited to publish it to public
    // ~: Spade was here :~ //
    $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : $_SERVER['HTTP_CLIENT_IP'];
    $link = "http://site.com/api.php?ip=".filter_var($ip, FILTER_VALIDATE_IP);//this is perfect for validating IP Address filter_shit
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $link);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $results = curl_exec($curl);
    curl_close($curl);
 
    foreach(json_decode($results) as $result => $res){
        echo "~ " .$result. " :: ".$res."\r\n";
    }
 
    // You can also use the below method
    /*
        // {"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.
        $res = json_decode($results, true);
        echo "IP: ".$res['ip']."\r\n";
        echo "Hostname: ".$res['hostname']."\r\n";
        echo "City: ".$res['city']."\r\n";
        echo "Zip Code: ".$res['zip']."\r\n";
        echo "Country: ".$res['country']."\r\n";
        echo "Country Code: ".$res['countryCode']."\r\n";
        echo "Location[lat/long]: "$res['location']."\r\n";
        echo "Time Zone: ".$res['timezone']."\r\n";
        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
    */
?>

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎