Giter Club home page Giter Club logo

Comments (1)

Orkuncakilkaya avatar Orkuncakilkaya commented on May 30, 2024

Hello @merlincom 👋 ,

Sorry for the late response. You should replace Fingerprint Pro Secret API Key with the secret api key that you can obtain from fingerprint dashboard.

You can follow these steps for obtaining api secret for your application:

  • Log in to https://dashboard.fingerprint.com/
  • Go to App Settings from left sidebar
  • Click on API Keys tab on the page
  • Copy the API Key on the table that has secret for type

Change the region according to your application's region. See the following code:

$config = Configuration::getDefaultConfiguration(FPJS_API_SECRET, Configuration::REGION_GLOBAL);

You can change Configuration::REGION_GLOBAL to these values REGION_GLOBAL, REGION_EUROPE, REGION_ASIA

For the requestId and the visitorId, you should get these values from your frontend. But for testing purposes, you can find those values by visiting your Fingerprint PRO page on dashboard. To get those values for testing purposes please follow these steps:

  • Log in to https://dashboard.fingerprint.com/
  • Go to Fingerprint PRO from left sidebar
  • Click on a row on the table
  • Copy the value next to requestId for requestId parameter
  • Copy the value next to visitorId for visitorId parameter

Let's have a quick scenario for an application that is hosted on the USA servers, that has a secret key as thisIsMySecretKey123, got a visit from a visitor that has id as aVisitorId123qwe and let's assume the requestId for that visit is 1234567890123.someRequest. The following code should be like this:

<?php

require_once(__DIR__ . '/vendor/autoload.php');

// Fingerprint Pro Secret API Key
const FPJS_API_SECRET = "thisIsMySecretKey123";
// A mandatory visitorId of a specific visitor
const FPJS_VISITOR_ID = "aVisitorId123qwe";
// An optional requestId made by a specific visitor
const FPJS_REQUEST_ID = "1234567890123.someRequest";

// 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 BEFORE = 1;

// 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_GLOBAL);
$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, BEFORE);
    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, BEFORE);
    echo "<pre>" . $response->__toString() . "</pre>";
} catch (Exception $e) {
    echo 'Exception when calling FingerprintApi->getEvent: ', $e->getMessage(), PHP_EOL;
}

If you need further help please don't hesitate to contact us!
Also you can follow documentations from this link for server api. https://dev.fingerprint.com/docs/server-api

Note: Please follow one of our use cases to how to get requestId and visitorId from your frontend application automatically when a visit occurs. https://fingerprint.com/use-cases/

from fingerprint-pro-server-api-php-sdk.

Related Issues (8)

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.