Go.cam provides two standard implementation examples, available in PHP and JavaScript.
This implementation generates a Go.cam verification URL based on your access keys.
It can be used in standalone mode if the age verification should run in a new browser window or via a redirect.
This method is designed to be straightforward and easy to follow. Below is a walkthrough.
Tip: A sample implementation can be downloaded from your Go.cam account.
require_once 'avsPhpSdkV1.php';
Retrieve the required credentials from your Go.cam account and edit the config.php file.
$config['partnerId'] = 0;
$config['cipherKey'] = '';
$config['hmacKey'] = '';
Initialize the SDK class in the index.php file.
$avsInstance = new AvsPhpSdkV1(
$config['partnerId'],
$config['cipherKey'],
$config['hmacKey']
);
By default, the test page is displayed in English. Supported languages:
English, French, German, Dutch, Italian, Portuguese, Spanish
$avsInstance->setLanguage(AvsPhpSdkV1::LANGUAGE_EN);
Go.cam uses AES-256-CBC encryption for secure communication.
For each session, you must define the payload, which may include required and optional parameters.
Example:
$avsInstance->fillRequest([
'userData' => [
// mandatory: partner internal user id, used for tracking the user
'userId' => $userId,
// optional: some custom data the partner want to include in this verification session
'someCustomData' => true,
// optional: custom colors for the interface of the Go.cam verification process
'colorConfig' => [
'body' => [
'background' => $colorConfigBodyBackground,
'foreground' => $colorConfigBodyForeground,
'button' => [
'background' => $colorConfigButtonBackground,
'foreground' => $colorConfigButtonForeground,
'foregroundCallToAction' => $colorConfigButtonForegroundCTA,
'backgroundFailure' => $colorConfigButtonBackgroundFailureInput,
'foregroundFailure' => $colorConfigButtonForegroundFailureInput,
'foregroundCallToActionFailure' => $colorConfigButtonForegroundCTAFailureInput,
]
],
] // optional
],
'http' => [
'userAgent' => $userAgent,
'websiteHostname' => $websiteHostname,
'paramList' => [
// optional: a way to control if the detected age number is shown on the screen during the selfie age verification process
'showDetectedAgeNumber' => $showDetectedAgeNumber,
// optional: the type of verification you want to show to the user
// if not specified as a parameter or it's empty all the types will be visible
'verificationTypeList' => array('creditCard', 'selfie', 'scanId', 'email'),
// optional: the type of verification you want to be selected as default
'verificationTypeDefault' => 'selfie',
// optional: use email verification as a fallback in case the first chosen verification fails
'useEmailAsFallbackVerification' => true,
// optional: a way to control if the selfie detection will use advanced liveness (use various checks to detect the person in the webcam is real)
'advancedLiveness' => $advancedLiveness,
]
],
// optional: the Go.cam verification version
'verificationVersion' => AvsPhpSdkV1::VERIFICATION_VERSION_STANDARD_V1,
// mandatory: the URL to get back to the partner site after a verification
'linkBack' => $linkBack,
// optional: ip of the user
'ipStr' => $userIp,
// optional: ISO country code of the user
'countryCode' => $countryCode,
// optional: ISO state code of the user (used for US mostly)
'stateCode' => $stateCode,
]);
$verificationUrl = $avsInstance->toUrl();
<a href="<?php echo $verificationUrl; ?>" target="_blank">Start age verification</a>
The postback URL must point to your backend, where you handle the callback data sent by Go.cam. See the Backend Callback Data Reference for details.
The iframe library builds upon the redirect library but allows Go.cam to run as an overlay iframe. It also provides lifecycle control and event handling for the verification process.
Tip: A sample implementation can be downloaded from your Go.cam account.
Instead of toUrl(), call:
$verificationUrl = $avsInstance->toIframeUrl();
<script src="avsJsSdkV1.js"></script>
<button id="openVerificationIframeButton" disabled>
Open verification iframe
</button>
var openVerificationIframeButton = document.querySelector('#openVerificationIframeButton');
var iframeUrl = ''; // generated from PHP above
AvsJsSdk.V1.Config.create({ iframeLocationUrl: iframeUrl });
var avsInstance = new AvsJsSdk.V1.Core();
avsInstance.init();
The SDK triggers events during the verification process. You can listen and react to them:
avsInstance.onMessage = function (eventMessage) {
switch (eventMessage.name) {
// check phase: iframe was loaded
case AvsJsSdk.V1.Config.EVENT_ON_CHECK_IFRAME_LOADED:
// send an event to the iframe for starting the verification process check phase
avsInstance.emit(AvsJsSdk.V1.Config.EVENT_STATUS_REQUEST);
break;
// check phase: age verification was successful on a previous verification process, user is already verified
case AvsJsSdk.V1.Config.EVENT_ON_INITIAL_VERIFICATION_SUCCESS:
// verification payload is valid
if (eventMessage.data.isPayloadValid) {
// disable the "start verification" button
openVerificationIframeButton.disabled = true;
return;
}
// verification payload is not valid, proceed with the verification process
avsInstance.emit(AvsJsSdk.V1.Config.EVENT_RESOURCE_PRELOAD);
break;
// check phase: age verification was not successful on a previous verification process or did not run at all
case AvsJsSdk.V1.Config.EVENT_ON_INITIAL_VERIFICATION_NOT_FOUND:
// check phase failed, proceed to the verification phase, send an event to start the verification phase resource preload
avsInstance.emit(AvsJsSdk.V1.Config.EVENT_RESOURCE_PRELOAD);
break;
// verification phase: iframe resources were loaded
case AvsJsSdk.V1.Config.EVENT_ON_RESOURCES_LOADED:
// enable the "start verification" button
openVerificationIframeButton.disabled = false;
// attach an click event to the "start verification" button
openVerificationIframeButton.addEventListener('click', function () {
// show the verification iframe as an overlay
avsInstance.iframeInstance.expand();
});
break;
// verification phase: iframe overlay close button was clicked
case AvsJsSdk.V1.Config.EVENT_ON_CLOSE_IFRAME:
// hide the verification iframe overlay (it's still running in the background)
avsInstance.iframeInstance.collapse();
break;
// verification phase: verification process was successful
case AvsJsSdk.V1.Config.EVENT_ON_VERIFICATION_SUCCESS:
// disable the "start verification" button
openVerificationIframeButton.disabled = true;
break;
}
}
When using the iframe library, the SDK may trigger the following events:
After each verification attempt (success or failure), Go.cam sends a server-to-server postback to notify your backend of the result.
The postback is delivered as an array with fields describing the verification session and its outcome.
[
'userData' => [
'userId' => 123,
'colorConfig' => [
'body' => [
'background' => '#900',
'foreground' => '#fff',
'button' => [
'background' => '#fb0',
'foreground' => '#333',
'foregroundCallToAction' => '#700',
'backgroundFailure' => '#fb0',
'foregroundFailure' => '#333',
'foregroundCallToActionFailure' => '#700',
]
]
]
],
'state' => 'Success',
'stateInt' => 2,
'sessionId' => 12345,
'errorCode' => 0,
'deviceType' => 1,
'stepId' => 2,
'websiteHostname' => 'your-site-name.cam',
'ip' => '127.0.0.1',
]
state
Indicates whether the verification was successful.
Possible value | Meaning |
---|---|
Success | the verification was successful |
Fail | the verification failed |
stateInt
Numeric representation of verification state.
Possible value | Meaning |
---|---|
0 | unknown |
1 | Test not started or aborted |
2 | Success |
3 | Failed |
4 | Link expired |
5 | Link already used |
sessionId
Unique identifier of the verification session.
Example: 12345
errorCode
Error code if the verification failed.
Possible value | Meaning |
---|---|
0 | No error |
25001 | Device it is not supported |
25032 | Preloading verification resources failed (face api resources) |
25033 | Preloading verification resources failed (tesseract resources) |
25034 | Could not retrieve your device camera list (selfie detection camera selection step) |
25055 | Could not detect enough faces from the device video (age detected is 0) |
25056 | Face similarity check fail (all selfie faces comparison) |
25057 | Could not detect enough faces from the device video (0 faces detected) |
25070 | No faces detected |
25061 | Could not detect enough faces from the device video (expression check fail) |
25062 | Face similarity check fail (expression faces comparison) |
25047 | Webcam initialization error (selfie detection step) |
25035 | Failed to initialize detection libraries (selfie detection step -> face api detector) |
25036 | Failed to initialize detection libraries (selfie detection step -> face api age model) |
25037 | Failed to initialize detection libraries (selfie detection step -> face api recognition model) |
25038 | Failed to initialize detection libraries (selfie detection step -> face api landmarks model) |
25058 | Failed to initialize detection libraries (selfie detection step -> face api expression model) |
25067 | Liveness face match check fail |
25069 | Liveness face match check fail |
25068 | Liveness check fail |
25039 | Could not retrieve your device camera list (scan id detection camera selection step) |
25040 | Failed to initialize detection libraries (scan id detection step -> tesseract worker) |
25041 | Failed to initialize detection libraries (scan id detection step -> tesseract language model) |
25042 | Failed to initialize detection libraries (scan id detection step -> tesseract language init) |
25043 | Failed to initialize detection libraries (scan id detection step -> tesseract worker config) |
25044 | Failed to initialize detection libraries (scan id detection step -> face api detector) |
25045 | Failed to initialize detection libraries (scan id detection step -> face api recognition model) |
25051 | Failed to extract a face from your identity card |
25052 | Selfie face does not match the one found on the identity card |
25053 | Detected age is lower than 18 years (scan id detection step) |
25075 | Detected age is lower than 18 years (selfie detection step) |
25054 | Failed to extract your age from the current identity card |
25046 | Webcam initialization error (scan id detection step) |
20056 | Invalid email age verification posted data |
20051 | Invalid captcha response |
20052 | Captcha check failed |
20053 | Email is not eligible |
20058 | Email eligibility response error |
20054 | Failed to send age email verification code |
20057 | Invalid verification code posted data |
20055 | Verification code check failed |
20061 | Invalid email address |
20002 | Test max allowed time expired (test success callback) |
20004 | Invalid step id (test success callback) |
20000 | Invalid token (test success callback) |
20034 | Invalid xcore api curl response (test success callback) |
20003 | Test max allowed time expired (test fail callback) |
20005 | Invalid step id (test fail callback) |
20001 | Invalid token (test fail callback) |
20035 | Invalid xcore api curl response (test fail callback) |
20036 | Detected age is lower than 18 years |
18001 | Credit card verification internal error |
18002 | Credit card verification maxmind error |
deviceType
Type of device used.
Possible value | Meaning |
---|---|
0 | unknown |
1 | mobile |
2 | desktop |
stepId
Stage of the verification process.
Possible value | Meaning |
---|---|
0 | unknown |
1 | Test not started or aborted |
2 | Success |
3 | Failed |
4 | Link expired |
5 | Link already used |
idCountry
ISO country code of the provided identity document.
Example: FR
idState
ISO state code of the provided identity document (mainly used for US).
Example: TX
idType
Type of identity document.
Possible value | Meaning |
---|---|
1 | Id card |
2 | Passport |
3 | Driver licence |
websiteHostname
Hostname of the website where the verification was initiated.
Example: your-site-name.cam
ip
IP address of the user’s device.
Example: 127.0.0.1
Choose GO.cam—the effortless, certified age verification solution for modern website operators.
Get Started Today!