PHP code example of lessotp / sdk
1. Go to this page and download the library: Download lessotp/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/ */
lessotp / sdk example snippets
use LessOTP\Sdk\Client;
use LessOTP\Sdk\VerificationChannel;
use LessOTP\Sdk\VerifyWebhookSignature;
// production (default)
$client = new Client(getenv('LESSOTP_API_KEY'), 'production', 'https://api.lessotp.com');
// staging
$staging = new Client(
getenv('LESSOTP_STAGING_API_KEY'),
'staging',
'https://api.lessotp.com'
);
// WhatsApp strict (legacy-compatible)
$result = $client->authRequest('6281234567890');
echo $result->getChannel()->value(), $result->getWaLink();
// WhatsApp frictionless (legacy-compatible)
$result = $client->authRequest();
// Telegram strict
$result = $client->requestTelegramAuth('6281234567890');
echo $result->getTelegramLink(), PHP_EOL;
echo $result->getTelegramText(), PHP_EOL;
// Telegram frictionless
$result = $client->requestAuth(VerificationChannel::telegram());
// per-call override
$result = $client->requestTelegramAuth('6281234567890', 'staging');
// webhook verification
$raw = file_get_contents('php://input');
$sig = $_SERVER['HTTP_X_SIGNATURE'] ?? '';
if (!VerifyWebhookSignature::hmac($raw, $sig, getenv('LESSOTP_WEBHOOK_SECRET'))) {
http_response_code(403);
exit;
}