PHP code example of vouchsafe / vouchsafe-php
1. Go to this page and download the library: Download vouchsafe/vouchsafe-php 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/ */
vouchsafe / vouchsafe-php example snippets
Vouchsafe\VouchsafeClient;
$client = new VouchsafeClient([
'client_id' => 'YOUR_CLIENT_ID',
'client_secret' => 'YOUR_SANDBOX_SECRET',
]);
// Request a verification
$res = $client->requestVerification([
'email' => '[email protected] '
]);
echo $res->getId();
echo $res->getUrl();
$list = $client->listVerifications(['status' => 'InProgress']);
$verification = $client->getVerification(['id' => 'abc123']);
$flows = $client->listFlows();
$result = $client->verifyPhotoId([
'sub_type' => 'DrivingLicence', // Passport | NationalId | DrivingLicence | PASSCard | UnfamiliarPhotoId
'front' => '/path/to/licence-front.jpg',
'country_code' => 'GB', // DrivingLicence only
// 'back' => '/path/to/back.jpg', // NationalId only
// 'face_scan' => '/path/to/selfie.jpg', // Optional selfie to face-match
]);
echo $result['outcome']; // 'pass' or 'fail'
echo $result['extracted_details']['first_name'];
try {
$res = $client->getVerification(['id' => 'non-existent']);
} catch (\Vouchsafe\VouchsafeApiError $e) {
echo $e->statusCode . ' ' . $e->getMessage();
}
composer