指纹识别 / fingerprint-pro-server-api-sdk
Fingerprint Pro Server API提供了验证Fingerprint Pro颁发的访客数据的方式。
Requires
- php: >=8.1
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- ext-zlib: *
- guzzlehttp/guzzle: ~7.2
Requires (Dev)
- phpunit/phpunit: 9.3.0
- vlucas/phpdotenv: ^5.6
This package is auto-updated.
Last update: 2024-09-09 14:56:51 UTC
README
Fingerprint Pro Server API PHP SDK
Fingerprint Pro Server API允许您在服务器环境中获取访客信息和单个事件的信息。它可用于数据导出、决策制定和数据分析场景。服务器API旨在服务器端使用,不适合从客户端使用,无论是浏览器还是移动设备。
此PHP包由Swagger Codegen项目自动生成
- API版本:3
- 包版本:5.0.0
- 构建包:io.swagger.codegen.v3.generators.php.PhpClientCodegen
要求
此库支持以下PHP实现
- PHP 8.1
- PHP 8.2
- PHP 8.3
我们目前不支持Bref、ReactPHP等外部PHP运行时
- Bref
- ReactPHP
安装与使用
Composer
要通过Composer安装绑定,请将以下内容添加到composer.json
{
"require": {
"fingerprint/fingerprint-pro-server-api-sdk": "dev-main"
}
}
然后运行composer install
。
或者您可以直接在终端运行此命令
composer require fingerprint/fingerprint-pro-server-api-sdk
入门
请按照安装过程进行,然后运行以下命令
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Fingerprint Pro Secret API Key const FPJS_API_SECRET = "Fingerprint Pro Secret API Key"; // A mandatory visitorId of a specific visitor const FPJS_VISITOR_ID = "visitorId"; // An optional requestId made by a specific visitor const FPJS_REQUEST_ID = "requestId"; // An optional linkedId of the visit const FPJS_LINKED_ID = "linkedId"; // An optional parameter limiting scanned results const LIMIT = 10; // An optional parameter used to paginate results, see lastTimestamp const PAGINATION_KEY = "1683900801733.Ogvu1j"; // Import Fingerprint Pro Classes and Guzzle Http Client use Fingerprint\ServerAPI\Api\FingerprintApi; use Fingerprint\ServerAPI\Configuration; use Fingerprint\ServerAPI\Model\EventUpdateRequest; use GuzzleHttp\Client; // Create a new Configuration instance with your Fingerprint Pro Server API Key and your Fingerprint Pro Server API Region. /** * You can specify a region on getDefaultConfiguration function's second parameter * If you leave the second parameter empty, then Configuration::REGION_GLOBAL will be used as a default region * Options for regions are: * Configuration::REGION_EUROPE * Congiruration::REGION_GLOBAL * Configuration::REGION_ASIA */ $config = Configuration::getDefaultConfiguration(FPJS_API_SECRET, Configuration::REGION_EUROPE); $client = new FingerprintApi( new Client(), $config ); // Get an event with a given requestId try { // Fetch the event with a given requestId list($model, $response) = $client->getEvent(FPJS_REQUEST_ID); echo "<pre>" . $response->__toString() . "</pre>"; } catch (Exception $e) { echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL; } // Get a specific visitor's all visits try { // Fetch all visits with a given visitorId, with a page limit list($model, $response) = $client->getVisits(FPJS_VISITOR_ID, null, null, LIMIT); echo "<pre>" . $response->__toString() . "</pre>"; } catch (Exception $e) { echo 'Exception when calling FingerprintApi->getVisits: ', $e->getMessage(), PHP_EOL; } // Get a specific visitor's all visits with a linkedId try { // Fetch all visits with a given visitorId, with a page limit, skipping the first visit list($model, $response) = $client->getVisits(FPJS_VISITOR_ID, null, FPJS_LINKED_ID, LIMIT, PAGINATION_KEY); echo "<pre>" . $response->__toString() . "</pre>"; } catch (Exception $e) { echo 'Exception when calling FingerprintApi->getVisits: ', $e->getMessage(), PHP_EOL; } // Use all the parameters on getVisits try { // Fetch the visitor's all visits with a given requestId and linkedId with a page limit while skipping the first visit list($model, $response) = $client->getVisits(FPJS_VISITOR_ID, FPJS_REQUEST_ID, FPJS_LINKED_ID, LIMIT, PAGINATION_KEY); echo "<pre>" . $response->__toString() . "</pre>"; } catch (Exception $e) { echo 'Exception when calling FingerprintApi->getVisits: ', $e->getMessage(), PHP_EOL; } // Update Event try { $body = new EventUpdateRequest([ 'linked_id' => 'new linked id', 'tag' => json_encode(['new_property' => 'new value']), 'suspect' => true, ]); list($model, $response) = $client->updateEvent($body, FPJS_REQUEST_ID); echo "<pre>" . $response->__toString() . "</pre>"; } catch (Exception $e) { echo 'Exception when calling FingerprintApi->updateEvent: ', $e->getMessage(), PHP_EOL; } // Delete by visitor ID try { list($model, $response) = $client->deleteVisitorData(FPJS_VISITOR_ID); echo "<pre>" . $response->__toString() . "</pre>"; } catch (Exception $e) { echo 'Exception when calling FingerprintApi->deleteVisitorData: ', $e->getMessage(), PHP_EOL; }
⚠️警告:无法更新10天前的旧事件。
⚠️如果您有兴趣使用
deleteVisitorData
API,请联系我们的支持团队以启用它。否则,您将收到403错误。
密封结果
此SDK提供了解码密封结果的实用方法。
<?php use Fingerprint\ServerAPI\Sealed\DecryptionAlgorithm; use Fingerprint\ServerAPI\Sealed\DecryptionKey; use Fingerprint\ServerAPI\Sealed\Sealed; require_once(__DIR__ . '/vendor/autoload.php'); $sealed_result = base64_decode($_ENV['BASE64_SEALED_RESULT']); $sealed_key = base64_decode($_ENV['BASE64_KEY']); try { $data = Sealed::unsealEventResponse($sealed_result, [new DecryptionKey($sealed_key, DecryptionAlgorithm::AES_256_GCM)]); fwrite(STDOUT, sprintf("Unsealed event: %s \n", $data)); } catch (Exception $e) { fwrite(STDERR, sprintf("Exception when unsealing event: %s\n", $e->getMessage())); exit(1); }
有关更多信息,请参阅位于sealed_results_example.php中的示例。
API端点文档
所有URI相对于您所在区域的基准URL。
Webhook签名
此SDK提供了验证传入Webhook请求的HMAC签名的实用方法。您可以使用以下代码验证签名
<?php use Fingerprint\ServerAPI\Webhook\WebhookVerifier; // Your webhook signing secret. $webhookSecret = "secret"; // Request data. In real life scenerio this will be the body of incoming request $webhookData = "data"; // Value of the "fpjs-event-signature" header. $webhookHeader = "v1=1b2c16b75bd2a870c114153ccda5bcfca63314bc722fa160d690de133ccbb9db"; $isValidWebhookSign = WebhookVerifier::IsValidWebhookSignature($webhookHeader, $webhookData, $webhookSecret); if(!$isValidWebhookSign) { fwrite(STDERR, sprintf("Webhook signature verification failed\n")); exit(1); }
端点
模型文档
- ASN
- BotdDetectionResult
- BotdResult
- BrowserDetails
- ClonedAppResult
- Common403ErrorResponse
- Confidence
- DataCenter
- DeprecatedIPLocation
- DeprecatedIPLocationCity
- DeveloperToolsResult
- EmulatorResult
- ErrorCommon403Response
- ErrorCommon429Response
- ErrorCommon429ResponseError
- ErrorEvent404Response
- ErrorEvent404ResponseError
- ErrorUpdateEvent400Response
- ErrorUpdateEvent400ResponseError
- ErrorUpdateEvent409Response
- ErrorUpdateEvent409ResponseError
- ErrorVisitor400Response
- ErrorVisitor400ResponseError
- ErrorVisitor404Response
- ErrorVisitor404ResponseError
- ErrorVisits403
- EventResponse
- EventUpdateRequest
- FactoryResetResult
- FridaResult
- HighActivityResult
- IPLocation
- IPLocationCity
- IdentificationError
- IncognitoResult
- IpBlockListResult
- IpBlockListResultDetails
- IpInfoResult
- IpInfoResultV4
- IpInfoResultV6
- JailbrokenResult
- Location
- LocationSpoofingResult
- PrivacySettingsResult
- ProductError
- ProductsResponse
- ProductsResponseBotd
- ProductsResponseIdentification
- 产品响应标识数据
- 代理结果
- 原始设备属性结果
- 远程控制结果
- 响应
- 响应访问
- 根应用结果
- 出现时间
- 信号响应克隆应用
- 信号响应开发者工具
- 信号响应模拟器
- 信号响应工厂重置
- 信号响应Frida
- 信号响应高活动
- 信号响应隐身模式
- 信号响应IP黑名单
- 信号响应IP信息
- 信号响应越狱
- 信号响应位置欺骗
- 信号响应隐私设置
- 信号响应代理
- 信号响应原始设备属性
- 信号响应远程控制
- 信号响应根应用
- 信号响应可疑分数
- 信号响应篡改
- 信号响应Tor
- 信号响应速度
- 信号响应虚拟机
- 信号响应VPN
- 子分区
- 可疑分数结果
- 篡改结果
- 过多请求响应
- Tor结果
- 速度区间结果
- 速度区间
- 速度结果
- 虚拟机结果
- 访问
- VPN结果
- VPN结果方法
- Webhook访问
授权文档
ApiKeyHeader
- 类型:API密钥
- API密钥参数名称:Auth-API-Key
- 位置:HTTP头
ApiKeyQuery
- 类型:API密钥
- API密钥参数名称:api_key
- 位置:URL查询字符串
密封结果文档
Webhook文档
测试
运行单元测试
composer install
./vendor/bin/phpunit
支持
要报告问题、提问或提供反馈,请使用问题。如果您需要私人支持,您可以给我们发送邮件至oss-support@fingerprint.com。
许可证
本项目采用MIT许可证。