PHP code example of verifykit / verifykit-sdk-php

1. Go to this page and download the library: Download verifykit/verifykit-sdk-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/ */

    

verifykit / verifykit-sdk-php example snippets


$vfk = new \VerifyKit\Web($serverKey, $clientIp);

/** @var \VerifyKit\Entity\ValidationMethodList $validationMethodList */
$validationMethodList = $vfk->getValidationMethodList();

/** @var \VerifyKit\Entity\ValidationMethod $validationMethod */
foreach ($validationMethodList->getList() as $validationMethod) {
    // $validationMethod-> getName, getApp, getText, getTextColour, getBgColour, getIcon...
}

// if you want to handle all localizations for validation steps, use this way.
/** @var \VerifyKit\Entity\Localization $localization */
foreach ($validationMethodList->getLocalizationList() as $localization){
    // getKey, getValue of localization.
}

$vfk = new \VerifyKit\Web($serverKey, $clientIp);

$validationMethod = 'whatsapp'; // or telegram. Required.

$lang = 'en'; // Language of end user. Default value is 'en' (English). This parameter is not coming from desktop browsers, you can make it easier to verify.
// We recommend that you do not send qrCode parameter as (bool)true for requests from mobile applications or mobile browsers. You should use deeplink for these platforms.
// This two parameters cannot be (bool)true at the same time. If you send both (bool)true at the same time, we will only give the deeplink in the response.
// Default value is true for deeplink, and false for qrCode. These parameters are not 

$vfk = new \VerifyKit\Web($serverKey, $clientIp);

$reference = "111111"; // reference from startValidation step.

/** @var \VerifyKit\Entity\ValidationCheck $validation */
$validationCheck = $vfk->checkValidation($reference);
if ($validationCheck->getValidationStatus()) {
    $sessionId = $validationCheck->getSessionId(); // session id for the validation result
    $appPlatform = $validationCheck->getAppPlatform(); // web, android or ios
}

$vfk = new \VerifyKit\Web($serverKey, $clientIp);

$countryCode = "TR"; // country code parameter for the request. We return the sent countryCode parameter at the top of the list in the response. If you want a specific country (user's country detected by ip on your side for example) to be the first response parameter, you can send $countryCode with your request. Not 

$vfk = new \VerifyKit\Web($serverKey, $clientIp);

$phoneNumber = '+90........'; // End user phone number. Required.

$countryCode = 'TR'; // Country code of the end user's phone number. This parameter should exist in the country list request's response array as only the listed countries could be used for OTP validations. Required.

// For OTP verification to work best, you should send us the MCC and MNC code of the sim card in the user's device.
$mcc = '999'; // Mobile Country Code (MCC) of the sim card in the user's device. Default value is '999'. Not 

$vfk = new \VerifyKit\Web($serverKey, $clientIp);

$phoneNumber = '+90........'; // End user phone number. Required.

$countryCode = 'TR'; // Country code of the end user's phone number. This parameter should exist in the country list request's response array as only the listed countries could be used for OTP vadlidations. Required.

$reference = "111111"; // reference from sendOtp step. Required.

$code = "123456"; // The code to be entered by the user receiving the OTP.

/** @var \VerifyKit\Entity\OtpCheck $validation */
$otpCheck = $vfk->checkOtp($phoneNumber, $countryCode, $reference, $code);
if ($otpCheck->getValidationStatus()) {
    $sessionId = $otpCheck->getSessionId(); // session id for the OTP validation result
}

$vfk = new \VerifyKit\VerifyKit($serverKey, $clientIp);

/** @var \VerifyKit\Entity\Response $result */
$result = $vfk->getResult($sessionId);

if ($result->isSuccess()) {
    echo "Phone number : " . $result->getPhoneNumber() .
        ", Validation Type : " . $result->getValidationType() .
        ", Validation Date : " . $result->getValidationDate()->format('Y-m-d H:i:s') . PHP_EOL;
} else {
    echo "Error message : " . $result->getErrorMessage() . ", error code : " . $result->getErrorCode() . PHP_EOL;
}

$waMessage = new \VerifyKit\WASessionMessage($serverKey, $clientIp);


/** @var \VerifyKit\Entity\WAMessageResponse $result */
$result = $waMessage->sendMessage($phoneNumber, $textMessage); // Phone number that you received using the session id in the previous method.

if ($result->isSuccess()) {
    echo "Phone number : " . $result->getPhoneNumber() . ", Message : " . $result->getMessage() . ", Status : " . $result->getStatus() . PHP_EOL;
} else {
    echo "Error message : " . $result->getErrorMessage() . ", error code : " . $result->getErrorCode() . PHP_EOL;
}

$vfk = new \VerifyKit\VerifyKit($serverKey, $clientIp);

/** @var \VerifyKit\Entity\AccessToken $result */
$result = $vfk->getWebAccessToken();

if ($result->isSuccess()) {
    echo "Access Token : " . $result->getAccessToken() .
        ", Timeout : " . $result->getTimeout()->format('Y-m-d H:i:s') . PHP_EOL;
} else {
    echo "Error message : " . $result->getErrorMessage() . ", error code : " . $result->getErrorCode() . PHP_EOL;
}
bash
composer