Closed merlincom closed 1 year ago
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:
App Settings
from left sidebarAPI Keys
tab on the pagesecret
for typeChange 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:
Fingerprint PRO
from left sidebarrequestId
for requestId
parametervisitorId
for visitorId
parameterLet'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/
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 a404 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";