Smile Identity
Search…
⌃K

Signature

Required Class: Signature Class

Generating a Signature

Smile Identity requires you to send a unique signature and timestamp with every job you run. Although running jobs using any of our libraries will automatically calculate the signature, there might be instances you want to run a job using our REST API or generate signatures. In such instances you can use the sample code below to calculate a signature:
<?php
require 'vendor/autoload.php';
// Initialize
$partner_id = "<Put your partner ID here>"; // login to the Smile Identity portal to view your partner id
$api_key = "<Put your API key here>"; // copy your API key from the Smile Identity portal
$sig_class = new Signature($partner_id, $api_key);
// Generate a signature
$signature_array = $sig_class->generate_signature("<put your custom timestamp>"); // where timestamp is optional
?>

Response

The response will be an array:
{
signature: '<the generated signature>',
timestamp: '2022-04-03T21:31:47.296Z'
}

Confirming an Incoming Signature

To ensure the response you receive from your callback is actually from Smile Identity, you can confirm the returned signature and timestamp. You can use the sample code below to confirm the signature:
<?php
require 'vendor/autoload.php';
// Initialize
$partner_id = "<Put your partner ID here>"; // login to the Smile Identity portal to view your partner id
$api_key = "<Put your API key here>"; // copy your API key from the Smile Identity portal
$sig_class = new Signature($partner_id, $api_key);
// Confirm a signature
$signature = $sig_class->confirm_signature("<put the received timestamp>","<put the received signature>");
?>

Response

The response will be a boolean
1 or ""
where 1 is true and blank is false