Trafficfilter.io v3 API 文档

V3 API 介绍

V3 是自Mixed版本升级而来,增加了浏览器指纹的行为验证,更加准确

V3 会返回访客 ID 的行为得分(0-100)

分数说明

Trafficfilter.io 会返回 0-100 的 IP 真人可信度分数(浏览器指纹分数)

分数范围 说明
96-100 此访客高概率是真人
50-95 有异常行为的真实设备
0-49 虚假或不受信任的设备

Trafficfilter.io 会返回 0-100 的 IP 真人可信度分数(IP分数)

分数范围 说明
86-100 此 IP 高概率是真人
71-85 此 IP 地址有可疑行为,有概率是真人
0-70 此 IP 地址有异常行为,真人概率低

快速使用指南(V3模式)

1·下载接入样例 从 https://trafficfilter.io/zh/request_blocking_v3-php.zip 下载接入样例,解压

(图1)

(图1)

2、放入安全页和落地页文件 我这里放入了anquan.html(安全页)和luodi.html(落地页)

(图2)

(图2)

3、上传到网站根目录

(图3)

(图3)

4、编辑index.php

(图4)

(图4)

关于IP分数

  • 推荐值是100最好,不严格的话85也行,如果你期望vpn等通过,就设置40-70,但是屏蔽效果会差很多

关于浏览器指纹分数

  • 推荐值是50,需要严格的过滤,可以在55-100之间尝试不同数值以达到期望效果

关于设备

  • windows和mac、linux等设备识别显示为desktop
  • ipad和大屏android设备会识别显示为tablet
  • iphone和小屏android设备会识别显示为mobile

5、访问测试,大功告成!

(图5)

(图5)

样例:请求过滤(PHP)(API v3)

index.php

<?php
$email = 'xxx@abc.com';//帐户Email
$password = '12345678';//帐户密码
$allow_country=['US','CA'];//允许的国家/地区 代码表:https://trafficfilter.io/zh/country.html
$allow_ip_score = 100; //允许的最低IP分数 分数范围0-100
$allow_fp_score = 100; //允许的最低指纹行为分数 分数范围0-100
$allow_device = ['desktop', 'tablet', 'mobile']; //允许的设备类型 desktop=电脑 tablet=平板 mobile=手机
$landing_page = 'landing_page.html'; //落地页文件名
$safe_page = 'safe_page.html'; //安全页文件名
session_start();
if (isset($_SESSION['trafficfilter_visitor_id'])) {
    if (isset($_SESSION['trafficfilter_result'])) {
        unset($_SESSION['trafficfilter_result']);
        include($landing_page);
    } else {
        $data = request_trafficfilter([
            'action' => 'get_result',
            'email' => $email,
            'password' => $password,
            'client_ip' => ip_trafficfilter(),
            'identifier' => $_SERVER['HTTP_HOST'],
            'data' => $_SESSION['trafficfilter_visitor_id']
        ]);
        if ($data['ip_score'] >= $allow_ip_score && $data['fingerprint_score'] >= $allow_fp_score && in_array($data['country'], $allow_country) && in_array($data['device'], $allow_device)) {
            include($landing_page);
        } else {
            echo file_get_contents($safe_page);
        }
    }
} else {
    if ($_SERVER['REQUEST_METHOD'] == 'GET') {
        $data = request_trafficfilter([
            'action' => 'get_replace',
            'email' => $email,
            'password' => $password,
        ]);
        $content = file_get_contents($safe_page);
        if (isset($data['search'][0]) && isset($data['replace'][0])) {
            $content = str_replace($data['search'], $data['replace'], $content);
        }
        echo $content;
    } else {
        $post_data = isset($_POST['_']) ? $_POST['_'] : '';
        $data = request_trafficfilter([
            'action' => 'get_result',
            'email' => $email,
            'password' => $password,
            'client_ip' => ip_trafficfilter(),
            'identifier' => $_SERVER['HTTP_HOST'],
            'data' => $post_data
        ]);
        if ($data['visitor_id']) {
            $_SESSION['trafficfilter_visitor_id'] = $data['visitor_id'];
            if ($data['ip_score'] >= $allow_ip_score && $data['fingerprint_score'] >= $allow_fp_score && in_array($data['country'], $allow_country) && in_array($data['device'], $allow_device)) {
                $_SESSION['trafficfilter_result'] = true;
                echo '1';
            }
        }
    }
}
function ip_trafficfilter()
{
    if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
            return $_SERVER['HTTP_CF_CONNECTING_IP'];
        } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $ip_arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
            return $ip_arr[0];
        } else {
            return $_SERVER['REMOTE_ADDR'];
        }
}
function request_trafficfilter($data)
{
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, 'https://trafficfilter.io/v3');
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    $res = curl_exec($curl);
    if (is_array(json_decode($res, true))) {
        $res = json_decode($res, true);
    } else {
        echo $res;
    }
    curl_close($curl);
    return $res;
}

landing_page.html

<!DOCTYPE html>
<html>
<head>
    <title>落地页</title>
</head>
<body>
    这个是您的落地页
</body>
</html>

safe_page.html

<html>
<head>
    <title>资源禁止访问</title>
</head>
<body>
    您的请求被禁止
</body>
</html>

下载这个样例(request_blocking_v3-php.zip)

Trafficfilter.io Mixed API 文档

Mixed API介绍

由于一些客户的要求,我们增加了Mixed API(v1 & v2),一次请求获得两种结果,可以更准确的过滤流量

快速使用指南(mixed模式)

1·下载接入样例 从 https://trafficfilter.io/zh/request_blocking_mixed-php.zip 下载接入样例,解压

(图1)

(图1)

2、放入安全页和落地页文件 我这里放入了anquan.html(安全页)和luodi.html(落地页)

(图2)

(图2)

3、上传到网站根目录

(图3)

(图3)

4、编辑index.php

(图4)

(图4)

​关于分数

  • 推荐值是100最好,不严格的话85也行,如果你期望vpn等通过,就设置40-70,但是屏蔽效果会差很多

关于设备

  • windows和mac、linux等设备识别显示为desktop
  • ipad和大屏android设备会识别显示为tablet
  • iphone和小屏android设备会识别显示为mobile

5、访问测试,大功告成!

(图5)

(图5)

样例:请求过滤(PHP)(API Mixed)

index.php

<?php
$email = 'xxx@abc.com';//帐户Email
$password = '12345678';//帐户密码
$allow_country=['US','CA'];//允许的国家/地区 代码表:https://trafficfilter.io/zh/country.html
$allow_ip_score=100;//允许的最低IP分数 分数范围0-100
$allow_device=['desktop','tablet','mobile'];//允许的设备类型 desktop=电脑 tablet=平板 mobile=手机
$landing_page = 'landing_page.html';//落地页文件名
$safe_page = 'safe_page.html';//安全页文件名
session_start();
if (isset($_SESSION['trafficfilter_result'])){
    if ($_SESSION['trafficfilter_result']) {
        include($landing_page);
    } else {
        echo file_get_contents($safe_page);
    }
}else{
    if ($_SERVER['REQUEST_METHOD'] == 'GET') {
            $data = request_trafficfilter([
                'action' => 'get_replace',
                'email' => $email,
                'password' => $password,
            ]);
            $content = file_get_contents($safe_page);
            if (isset($data['search'][0]) && isset($data['replace'][0])){
                $content = str_replace($data['search'],$data['replace'],$content);
            }
            echo $content;
    } else {
        $post_data=isset($_POST['_'])?$_POST['_']:'';
        if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
            $ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
        } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $ip_arr = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
            $ip = $ip_arr[0];
        } else{
            $ip = $_SERVER['REMOTE_ADDR'];
        };
        $data = request_trafficfilter([
            'action' => 'get_result',
            'email' => $email,
            'password' => $password,
            'client_ip' =>$ip,
            'identifier'=>$_SERVER['HTTP_HOST'],
            'data'=>$post_data
        ]);
        if ($data['fingerprint_result'] && $data['score']>=$allow_ip_score && in_array($data['country'],$allow_country) && in_array($data['device'],$allow_device)){
            $_SESSION['trafficfilter_result']=true;
            echo '1';
        } else {
            $_SESSION['trafficfilter_result']=false;
        }
    }
}
function request_trafficfilter($data){
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, 'https://trafficfilter.io/mixed');
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    $res = curl_exec($curl);
    if (is_array(json_decode($res,true))){
        $res = json_decode($res, true);
    }else{
        echo $res;
    }
    curl_close($curl);
    return $res;
}
?>

landing_page.html

<!DOCTYPE html>
<html>
<head>
    <title>落地页</title>
</head>
<body>
    这个是您的落地页
</body>
</html>

safe_page.html

<html>
<head>
    <title>资源禁止访问</title>
</head>
<body>
    您的请求被禁止
</body>
</html>

下载这个样例(request_blocking_mixed-php.zip)

Trafficfilter.io v2 API 接口文档

为什么是浏览器指纹

在网页浏览信号中,浏览器指纹的唯一性高,准确率最高

在V2版本中,我们使用浏览器指纹作为识别信号

样例:请求过滤(PHP)(API v2)

index.php

<?php
$email = 'xxx@abc.com';//帐户Email
$password = '12345678';//帐户密码
$allow_device=['desktop','tablet','mobile'];//允许的设备类型 desktop=电脑 tablet=平板 mobile=手机
$landing_page = 'landing_page.html';//落地页文件名
$safe_page = 'safe_page.html';//安全页文件名
session_start();
if (isset($_SESSION['trafficfilter_result'])){
    if ($_SESSION['trafficfilter_result']) {
        include($landing_page);
    } else {
        echo file_get_contents($safe_page);
    }
}else{
    if ($_SERVER['REQUEST_METHOD'] == 'GET') {
            $data = request_trafficfilter([
                'action' => 'get_replace',
                'email' => $email,
                'password' => $password,
            ]);
            $content = file_get_contents($safe_page);
            if (isset($data['search'][0]) && isset($data['replace'][0])){
                $content = str_replace($data['search'],$data['replace'],$content);
            }
            echo $content;
    } else {
        $post_data=isset($_POST['_'])?$_POST['_']:'';
        if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
            $ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
        } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $ip_arr = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
            $ip = $ip_arr[0];
        } else{
            $ip = $_SERVER['REMOTE_ADDR'];
        };
        $data = request_trafficfilter([
            'action' => 'get_result',
            'email' => $email,
            'password' => $password,
            'data'=>$post_data
        ]);
        if ($data['fingerprint_result'] && in_array($data['device'],$allow_device)){
            $_SESSION['trafficfilter_result']=true;
            echo '1';
        } else {
            $_SESSION['trafficfilter_result']=false;
        }
    }
}
function request_trafficfilter($data){
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, 'https://trafficfilter.io/v2');
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    $res = curl_exec($curl);
    if (is_array(json_decode($res,true))){
        $res = json_decode($res, true);
    }else{
        echo $res;
    }
    curl_close($curl);
    return $res;
}
?>

landing_page.html

<!DOCTYPE html>
<html>
<head>
    <title>落地页</title>
</head>
<body>
    这个是您的落地页
</body>
</html>

safe_page.html

<html>
<head>
    <title>资源禁止访问</title>
</head>
<body>
    您的请求被禁止
</body>
</html>

下载这个样例(request_blocking_v2-php.zip)

Trafficfilter.io v1 API文档

快速开始

请求示例:

curl https://trafficfilter.io/v1  -X POST -d 'email=abc@abc.com&password=Your Password&ip=8.8.8.8&identifier=domain.com'

参数说明:

参数名称 是否必填 说明
email Trafficfilter.io用户名
password Trafficfilter.io密码
ip 客户端ip地址
identifier 网站域名

响应结果:

{
  "ip":"8.8.8.8",
  "country":"US",
  "score":100
}

参数说明:

参数名称 类型 说明
ip String ip地址
country String IP归属 国家/地区
score Integer 可信分数(最大100;最小0)

分数说明

Trafficfilter.io 会返回 0-100 的 IP 真人可信度分数

分数范围 说明
86-100 此 IP 高概率是真人
71-85 此 IP 地址有可疑行为,有概率是真人
0-70 此 IP 地址有异常行为,真人概率低

国家/地区代码表

查看国家地区代码表

样例:请求过滤(PHP)(API v1)

index.php

<?php
$email = 'xxx@abc.com';//帐户Email
$password = '12345678';//帐户密码
$allow_country=['US','CA'];//允许的国家/地区 代码表:https://trafficfilter.io/zh/country.html
$allow_ip_score=100;//允许的最低IP分数 分数范围0-100
$landing_page = 'landing_page.html';//落地页文件名
$safe_page = 'safe_page.html';//安全页文件名
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
    $ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $ip_arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
    $ip = $ip_arr[0];
} else {
    $ip = $_SERVER['REMOTE_ADDR'];
};
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://trafficfilter.io/v1');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query([
    'email' => $email,
    'password' => $password,
    'ip' => $ip,
    'identifier' => $_SERVER['HTTP_HOST']
]));
$res = json_decode(curl_exec($curl), true);
curl_close($curl);
if (in_array($res['country'], $allow_country) && $res['score'] >= $allow_score) {
    include($landing_page);
} else {
    include($safe_page);
}
?>

*代码中 'US', 'CA' 和 "75" 是参考值, 请根据实际情况调整

*当判断分数参数>=95时,比市面上大部分"Cloak"工具准确

landing_page.html

<!DOCTYPE html>
<html>
<head>
    <title>落地页</title>
</head>
<body>
    这个是您的落地页
</body>
</html>

safe_page.html

<html>
<head>
    <title>资源禁止访问</title>
</head>
<body>
    您的请求被禁止
</body>
</html>

下载这个样例(request_blocking_v1.zip)