PHP code example of ums-lspl / photosign-verification-client
1. Go to this page and download the library: Download ums-lspl/photosign-verification-client 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/ */
ums-lspl / photosign-verification-client example snippets
use PhotoSign\Facades\PhotoSign;
use PhotoSign\Exceptions\ValidationFailedException;
use PhotoSign\Exceptions\PhotoSignUnavailableException;
try {
$result = PhotoSign::validatePhoto($this->photo, [
'profile' => config('photosign.photo_profile'),
'reference_id' => auth()->user()->STUDENTCODE,
'locale' => app()->getLocale(), // en | hi
]);
// Soft tips when ok is true but lighting/contrast is imperfect:
// foreach ($result->tipMessages() as $tip) { ... }
} catch (ValidationFailedException $e) {
$this->addError('photo', $e->getMessage());
foreach ($e->issues() as $issue) {
// $issue->code, $issue->message, $issue->hint, $issue->severity
}
return;
} catch (PhotoSignUnavailableException $e) {
$this->addError('photo', 'Photo validation is temporarily unavailable.');
return;
}
PhotoSign::validatePhoto($dataUrl, [
'reference_id' => auth()->user()->STUDENTCODE,
]);
$decoded = PhotoSign::decodeDataUrl($dataUrl);
Storage::disk('s3')->put("profile/{$code}.{$decoded['extension']}", $decoded['contents']);
PhotoSign::validateSignature($this->signature, [
'reference_id' => auth()->user()->STUDENTCODE.'-sign',
]);
PhotoSign::enrollSignature($enrolmentSignature, $studentCode);
PhotoSign::validateSignature($examSignature, ['reference_id' => $studentCode]);
$batch = PhotoSign::validateBatch([
['file' => $photo, 'kind' => 'photo'],
['file' => $signature, 'kind' => 'signature', 'reference_id' => $studentCode],
]);
$raw = $request->getContent();
$ok = PhotoSign::verifyWebhookSignature(
config('photosign.webhook_secret'),
$raw,
(string) $request->header('X-PhotoSign-Signature'),
);
$session = PhotoSign::createCaptureSession([
'kind' => 'photo',
'reference_id' => auth()->user()->STUDENTCODE,
'allowed_origin' => config('app.url'),
'locale' => app()->getLocale(), // appends ?locale=hi to embed_url
]);