Giter Club home page Giter Club logo

fingerprint-pro-server-api-php-sdk's Introduction

Fingerprint logo

CI badge CI badge CI badge Latest Stable Version on Packagist PHP Version Require Discord server

Fingerprint Pro Server API PHP SDK

Fingerprint Pro Server API allows you to get information about visitors and about individual events in a server environment. It can be used for data exports, decision-making, and data analysis scenarios. Server API is intended for server-side usage, it's not intended to be used from the client side, whether it's a browser or a mobile device.

This PHP package is automatically generated by the Swagger Codegen project:

  • API version: 3
    • Package version: 4.1.0
  • Build package: io.swagger.codegen.v3.generators.php.PhpClientCodegen

Requirements

This library supports the following PHP implementations:

  • PHP 8.1
  • PHP 8.2
  • PHP 8.3

We currently don't support external PHP Runtimes like:

  • Bref
  • ReactPHP

Installation & Usage

Composer

To install the bindings via Composer, add the following to composer.json:

{
    "require": {
        "fingerprint/fingerprint-pro-server-api-sdk": "dev-main"
    }
}

Then run composer install.

Or you can just run this command on your terminal:

composer require fingerprint/fingerprint-pro-server-api-sdk

Getting Started

Please follow the installation procedure and then run the following:

<?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 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
    $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
    $response = $client->getVisits(FPJS_VISITOR_ID, null, null, LIMIT);
    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 with a linkedId
try {
    // Fetch all visits with a given visitorId, with a page limit, skipping the first visit
    $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->getEvent: ', $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
    $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->getEvent: ', $e->getMessage(), PHP_EOL;
}

Sealed results

This SDK provides utility methods for decoding sealed results.

<?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);
}

To learn more, refer to example located in sealed_results_example.php.

Documentation for API Endpoints

All URIs are relative to your region's base URL.

Region BasePath
US / Global https://api.fpjs.io
Europe https://eu.api.fpjs.io
Asia https://ap.api.fpjs.io

Endpoints

Class Method HTTP request Description
FingerprintApi getEvent GET /events/{request_id} Get event by requestId
FingerprintApi getVisits GET /visitors/{visitor_id} Get visits by visitorId

Documentation for Models

Documentation for Authorization

ApiKeyHeader

  • Type: API key
  • API key parameter name: Auth-API-Key
  • Location: HTTP header

ApiKeyQuery

  • Type: API key
  • API key parameter name: api_key
  • Location: URL query string

Documentation for sealed results

Tests

To run the unit tests:

composer install
./vendor/bin/phpunit

Support

To report problems, ask questions or provide feedback, please use Issues. If you need private support, you can email us at [email protected].

License

This project is licensed under the MIT License.

fingerprint-pro-server-api-php-sdk's People

Contributors

dependabot[bot] avatar ilfa avatar jurouhlar avatar makma avatar orkuncakilkaya avatar semantic-release-bot avatar theunderscorer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fingerprint-pro-server-api-php-sdk's Issues

Exception when calling FingerprintApi->getEvent: [404]

Hallo guys

I am trying to use Fingerprint on my own web server. I installed it with Composer and started with a website as described on https://github.com/fingerprintjs/fingerprint-pro-server-api-php-sdk/blob/main/README.md. I am not sure if I should replace "Fingerprint Pro Secret API Key" with my Application API Keey from fingerprint.com (secret key)? And what should I replace "visitorId" with? With the public key? I am confused. Thanks for some advice.

Exception when calling FingerprintApi->getEvent: [404] Client error: GET https://eu.api.fpjs.io/events/?ii=fingerprint-pro-server-php-sdk%2F1.0.1&api_key=<redacted> resulted in a 404 Not Found response: {"error":{"code":"RequestNotFound","message":"request id is not found"}}

// 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";

Get rid of ArrayAccess methods warnings

Running run_checks.php you get a lot of these warnings:

Deprecated: Return type of Fingerprint\ServerAPI\Model\SignalResponseTor::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jurajuhlar/Documents/Code/php-server-sdk/src/Model/SignalResponseTor.php on line 271
PHP Deprecated:  Return type of Fingerprint\ServerAPI\Model\SignalResponseTor::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jurajuhlar/Documents/Code/php-server-sdk/src/Model/SignalResponseTor.php on line 284

They might be suppressed now at the script level but they are there. We might be able to get rid of them as the message suggest by adjusting our generation templates, here is the related generator issue:

swagger-api/swagger-codegen#11820

Update to newer Guzzle

Hi team,

Is there any chance you can upgrade the library to support Laravel 9, as I get the following error when installing:

charlie@Charlies-MacBook-Pro test-project % composer require fingerprint/fingerprint-pro-server-api-sdk         
./composer.json has been updated
Running composer update fingerprint/fingerprint-pro-server-api-sdk
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - fingerprint/fingerprint-pro-server-api-sdk[dev-feat/swagger-update-schemas-seen-at, dev-main, dev-develop, 0.0.1, ..., 0.4.1, 1.0.0, ..., 1.0.1] require guzzlehttp/guzzle ^6.2 -> found guzzlehttp/guzzle[6.2.0, ..., 6.5.x-dev] but it conflicts with your root composer.json require (^7.2).
    - Root composer.json requires fingerprint/fingerprint-pro-server-api-sdk * -> satisfiable by fingerprint/fingerprint-pro-server-api-sdk[dev-feat/swagger-update-schemas-seen-at, dev-main, dev-develop, 0.0.1, 0.3.0, 0.4.0, 0.4.1, 1.0.0, 1.0.1, 9999999-dev].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require fingerprint/fingerprint-pro-server-api-sdk:*" to figure out if any version is installable, or "composer require fingerprint/fingerprint-pro-server-api-sdk:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.
charlie@Charlies-MacBook-Pro test-project % 

v3 not available in composer

Running to Upgrade from version 2

composer require fingerprint/fingerprint-pro-server-api-sdk:^3

Gives an error:

Problem 1
    - Root composer.json requires fingerprint/fingerprint-pro-server-api-sdk 3, found fingerprint/fingerprint-pro-server-api-sdk[dev-main, dev-INTER-481-fixed-datacenter-name, dev-develop, 0.0.1, 0.3.0, 0.4.0, 0.4.1, 1.0.0, ..., 1.2.2, 2.0.0, 2.1.0, 2.1.1, 2.2.0] but it does not match the constraint.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.