1. Go to this page and download the library: Download proofage/php-sdk 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/ */
proofage / php-sdk example snippets
use ProofAge\Sdk\Client;
$client = new Client([
'api_key' => getenv('PROOFAGE_API_KEY'),
'secret_key' => getenv('PROOFAGE_SECRET_KEY'),
'base_url' => 'https://api.proofage.xyz',
]);
$workspace = $client->workspace()->get();
$verification = $client->verifications()->create([
'callback_url' => 'https://example.com/verification/done', // where the browser goes afterwards
'external_id' => 'user-42',
]);
$verification['url']; // the link the person opens
\ProofAge\Sdk\Enums\VerificationStatus::tryFrom($verification['status']);
$v = $client->verifications($verification['id']);
$v->get();
$v->acceptConsent(['consent_version_id' => $consent['id'], 'text_sha256' => $consent['text_sha256']]);
$v->uploadMedia(['type' => 'document', 'side' => 'front', 'document' => 'passport', 'file' => '/tmp/front.jpg']);
$v->uploadMedia(['type' => 'selfie', 'file' => new \SplFileInfo('/tmp/selfie.jpg')]);
$v->submit();
$v->document();
$v->estimation();
$v->blockFace(['reason_code' => \ProofAge\Sdk\Enums\BlockFaceReasonCode::UNDERAGE->value]);
$client->workspace()->get();
$client->workspace()->getConsent();
use ProofAge\Sdk\Exceptions\AuthenticationException; // 401
use ProofAge\Sdk\Exceptions\ValidationException; // 422, getErrors()
use ProofAge\Sdk\Exceptions\TransportException; // connection refused, DNS, TLS, timeout
use ProofAge\Sdk\Exceptions\ProofAgeException; // every other non-2xx, and the base class
use ProofAge\Sdk\Exceptions\ExceptionInterface; // marker: catch the whole family
try {
$client->verifications()->create($data);
} catch (ValidationException $e) {
$errors = $e->getErrors();
} catch (TransportException $e) {
// no response: $e->getResponse() is null, $e->getCode() is the cURL errno
} catch (ProofAgeException $e) {
$e->getCode(); // HTTP status
$e->getErrorCode(); // e.g. MEDIA_NOT_FOUND, PAYMENT_METHOD_REQUIRED, FACE_NOT_FOUND; null when the body has none
$e->getErrorData(); // the `error` object, or the whole body when it is not nested
$e->getResponse(); // ProofAge\Sdk\Http\Response
}
use ProofAge\Sdk\Webhooks\WebhookVerifier;
use ProofAge\Sdk\Exceptions\WebhookVerificationException;
$verifier = new WebhookVerifier(getenv('PROOFAGE_API_KEY'), getenv('PROOFAGE_SECRET_KEY'));
try {
$verifier->verifyHeaders(getallheaders(), file_get_contents('php://input'));
} catch (WebhookVerificationException $e) {
http_response_code($e->statusCode);
echo json_encode($e->toArray()); // {"error": {"code": "INVALID_SIGNATURE", "message": "..."}}
exit;
}
use ProofAge\Sdk\Http\Request;
use ProofAge\Sdk\Http\Response;
$client->pushMiddleware(function (Request $request, callable $next): Response {
return $next($request->withHeader('X-Request-Id', bin2hex(random_bytes(8))));
}, 'request-id');
// Once per logical call rather than per attempt:
$client->pushMiddleware(function (Request $request, callable $next): Response {
if ($request->attempt === 1) {
$quota->consume();
}
return $next($request);
});
$client->removeMiddleware('request-id');
use ProofAge\Sdk\Http\Psr18\Psr18HttpClient;
$factory = new \GuzzleHttp\Psr7\HttpFactory;
$transport = new Psr18HttpClient(new \GuzzleHttp\Client(['timeout' => 30]), $factory, $factory);
$client = new Client($config, $transport);