PHP code example of alexstewartja / php-didit

1. Go to this page and download the library: Download alexstewartja/php-didit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alexstewartja / php-didit example snippets


// Replace these example credentials with your own...
$client_id = 'AcL8JK38FqNPmx20qrd3-b';
$client_secret = 'QuajPJsV0sKiQ3M33fd4RK2rVofEmHXLolKW_ZeyeNL';

$token_info = Didit::getAccessToken($client_id, $client_secret);
$access_token = $token_info->getAccessToken();
// Store your access token securely...

$access_token = 'eyJhbGciOiAiUlMyNTYiLCAidHlwIjogIkpXVCJ9...'; // Retrieved from secure storage
$vendor_data = 'c4afad98-e044-4a5f-b68f-5ffaaaefe6a0'; // Commonly, a unique id/uuid of the user in your application
$callback = 'https://verify.didit.me/'; // URL to redirect your user after they complete verification
$features = VerificationFeatures::OCR_FACE; // Optional verification features to enable

$session = Didit::createVerificationSession($access_token, $vendor_data, $callback);
$session_id = $session->getSessionId();
// Store your session ID for future reference, commonly as part of your user record...
$session_url = $session->getSessionUrl();
// Redirect your user to the verification URL...

$access_token = 'eyJhbGciOiAiUlMyNTYiLCAidHlwIjogIkpXVCJ9...'; // Retrieved from secure storage
$session_id = 'e8933296-fa3b-4a7a-9c99-b132d34b19fc'; // Retrieved from user record

$session = Didit::getVerificationSession($access_token, $session_id);

$access_token = 'eyJhbGciOiAiUlMyNTYiLCAidHlwIjogIkpXVCJ9...'; // Retrieved from secure storage
$session_id = 'e8933296-fa3b-4a7a-9c99-b132d34b19fc'; // Retrieved from user record
$new_status = VerificationStatus::DECLINED;
$comment = 'User is from a country that is no longer supported'; // Optional comment/reason for review

$declined = Didit::updateVerificationSessionStatus($access_token, $session_id, $new_status, $comment);
if ($declined) {
    // Status update was successful...
}

$access_token = 'eyJhbGciOiAiUlMyNTYiLCAidHlwIjogIkpXVCJ9...'; // Retrieved from secure storage
$session_id = 'e8933296-fa3b-4a7a-9c99-b132d34b19fc'; // Retrieved from user record
$save_to = './session_pdf_downloads/session.pdf'; // Optional file path to store generated PDF

$generated = Didit::generateVerificationSessionPdf($access_token, $session_id, $save_to);
if ($generated) {
    // PDF generated and stored successfully...
}
bash
composer