Trustip
HomeFeaturesAboutPricing
  • Get Started
  • Code Examples
    • PHP
    • Laravel
    • Node js
    • JavaScript
  • API Rate Limits
Powered by GitBook
On this page

Was this helpful?

  1. Code Examples

PHP

You can call our API using PHP by using the code examples below or by creating your code.

Using PHP file_get_contents():


$ip = $_SERVER["REMOTE_ADDR"] // Visitor IP Address;

$api_key = 'YOUR_API_KEY';

$url = "https://api.trustip.io/v1/check.php?key={$api_key}&ip={$ip}";

$json = file_get_contents($url);

$response = json_decode($json, true);

if($response['status'] == 'success'){
    if($response['data']['is_proxy']) {
        echo 'IP address is a proxy';
    } else {
        echo 'IP address is not a proxy';
    }
} else {
    die($response['message']);
}

Or via CURL:


$ip = $_SERVER["REMOTE_ADDR"] // Visitor IP Address;

$api_key = 'YOUR_API_KEY';
    
$url = "https://api.trustip.io/v1/check.php?key={$api_key}&ip={$ip}";

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($curl);

curl_close($curl);

$response = json_decode($result, true);

if($response['status'] == 'success'){
    if($response['data']['is_proxy']) {
        echo 'IP address is a proxy';
    } else {
        echo 'IP address is not a proxy';
    }
} else {
    die($response['message']);
}
PreviousCode ExamplesNextLaravel

Last updated 1 year ago

Was this helpful?