PHP code example of verifymyagecouk / verifymyage-oauth
1. Go to this page and download the library: Download verifymyagecouk/verifymyage-oauth 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/ */
verifymyagecouk / verifymyage-oauth example snippets
use VerifyMyAge\OAuthV3;
use VerifyMyAge\Countries;
use VerifyMyAge\Methods;
use VerifyMyAge\Webhook;
$oauth = new OAuthV3(
'your-api-key',
'your-api-secret',
'https://your-app.com/callback'
);
// Optional: use sandbox for development
$oauth->useSandbox();
$result = $oauth->getStartVerificationUrl(
country: Countries::UNITED_KINGDOM,
method: Methods::ID_SCAN, // optional
businessSettingsId: 'your-business-settings-id', // optional
externalUserId: 'user-123', // optional
webhook: 'https://your-app.com/webhook', // optional
webhookNotificationLevel: Webhook::DETAILED_NOTIFICATION_LEVEL, // optional
userInfo: ['email' => '[email protected]'], // optional
);
// Instant approval — no user interaction needed
if ($result['verification_status'] === 'approved') {
// User is already approved
}
// User interaction
$verification = $oauth->getVerification($verificationId);
// Possible statuses: started | pending | approved | failed | expired
echo $verification['status'];
// List all registered redirect URLs for this account
$urls = $oauth->getAllowedRedirects();
// Append new URLs (does not replace the existing list)
$oauth->addAllowedRedirects([
'https://your-app.com/callback',
'https://your-app.com/alt-callback',
]);
use VerifyMyAge\OAuthV2;
use VerifyMyAge\Countries;
use VerifyMyAge\Methods;
use VerifyMyAge\Webhook;
$oauth = new OAuthV2(
'your-client-id',
'your-client-secret',
'https://your-app.com/callback'
);
$oauth->useSandbox(); // optional
// Start verification
$result = $oauth->getStartVerificationUrl(
country: Countries::UNITED_KINGDOM,
method: Methods::ID_SCAN,
businessSettingsId: 'your-business-id',
externalUserId: 'user-123',
verificationId: '',
webhook: 'https://your-app.com/webhook',
webhookNotificationLevel: Webhook::DETAILED_NOTIFICATION_LEVEL,
stealth: false,
userInfo: ['email' => '[email protected]'],
);
if (isset($result['start_verification_url'])) {
header('Location: ' . $result['start_verification_url']);
exit;
}
// On callback: exchange the code for a token
$token = $oauth->exchangeCodeByToken($_GET['code']);
// Retrieve user/verification data
$user = $oauth->user($token);
use VerifyMyAge\OAuthV1;
$oauth = new OAuthV1($clientId, $clientSecret, $redirectUrl);
$result = $oauth->getStartVerificationUrl(
country: Countries::UNITED_KINGDOM,
method: Methods::ID_SCAN,
);
// On callback: exchange the code for a token
$token = $oauth->exchangeCodeByToken($_GET['code']);
use VerifyMyAge\OAuth;
$oauth = new OAuth($clientId, $clientSecret, $redirectUrl);
// Redirect user to the VerifyMyAge authorization page
$authUrl = $oauth->redirectURL(Countries::UNITED_KINGDOM, Methods::ID_SCAN);
header('Location: ' . $authUrl);
exit;
// On callback: exchange the code for a token
$token = $oauth->exchangeCodeByToken($_GET['code']);
$user = $oauth->user($token);
$oauth->useSandbox();
try {
$result = $oauth->getStartVerificationUrl(country: Countries::UNITED_KINGDOM);
} catch (\Exception $e) {
$error = json_decode($e->getMessage(), true);
// $error['code'] contains the HTTP status code (for API errors)
error_log($e->getMessage());
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.