lessotp/sdk
Composer 安装命令:
composer require lessotp/sdk
包简介
LessOTP Inbound WhatsApp Authentication client SDK for PHP.
README 文档
README
Client for the LessOTP Inbound WhatsApp Authentication API (PHP 7.4+).
Install
composer require lessotp/sdk
Usage
use LessOTP\Sdk\Client; use LessOTP\Sdk\VerifyWebhookSignature; // production (default) $client = new Client(getenv('LESSOTP_API_KEY'), 'https://api.lessotp.com'); // staging $staging = new Client( getenv('LESSOTP_STAGING_API_KEY'), 'https://api.lessotp.com', null, 10, 'staging' ); // strict $result = $client->authRequest('6281234567890'); echo $result->getRequestId(), PHP_EOL; // frictionless $result = $client->authRequest(); // per-call override $result = $client->authRequest('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; }
API
new Client($apiKey, $baseUrl = 'https://api.lessotp.com', $http = null, $timeoutSeconds = 10, $environment = 'production')
| Parameter | Default | Description |
|---|---|---|
$apiKey |
required | App API key. |
$baseUrl |
https://api.lessotp.com |
API host. |
$http |
null |
Optional GuzzleHttp\Client. |
$timeoutSeconds |
10 |
HTTP timeout. |
$environment |
'production' |
'production' or 'staging'. |
$client->authRequest($phoneNumber = null, $environment = null): AuthRequestResult
Calls the endpoint selected by $environment. The per-call $environment overrides the client environment.
VerifyWebhookSignature::hmac($rawBody, $signatureHeader, $secret): bool
Constant-time HMAC-SHA256 verification. Accepts raw hex and sha256= prefixed values.
Errors
Throws LessOTP\Sdk\LessOTPException on transport, auth, or payload problems.
Tests
composer install
composer test
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-20