verixo/sdk
Composer 安装命令:
composer require verixo/sdk
包简介
Official PHP SDK for the Verixo OTP-as-a-Service API
README 文档
README
Official PHP SDK for the Verixo OTP-as-a-Service API.
Install
composer require verixo/sdk
Quickstart
use Verixo\Client; $vc = new Client(getenv('VC_API_KEY')); $result = $vc->numbers->search([ 'serviceSlug' => 'whatsapp', 'countryCode' => 'NG', 'minScore' => 80, 'limit' => 5, ]); $session = $vc->numbers->purchase([ 'serviceSlug' => 'whatsapp', 'countryCode' => 'NG', ]); $vc->subscribe($session->sessionToken, function ($push) { echo "OTP: {$push->otp} in {$push->latencyMs}ms\n"; });
Note: purchase() takes serviceSlug + countryCode, not a specific
numberId -- the server picks the best available number by Health Score at
purchase time, since a candidate returned by search() could already be gone
by the time you'd reference it back.
subscribe() is synchronous, unlike the Node/Python SDKs
PHP scripts typically run to completion rather than holding an event loop
open, so subscribe() blocks the calling script until the OTP arrives or
$timeoutSeconds elapses (default 90s) -- it doesn't return an unsubscribe
handle. It returns the OtpPush (also passed to your callback), or null on
timeout.
Polling instead of real-time push
$result = $vc->sessions->waitForOtp($session->sessionToken, timeoutSeconds: 90); if ($result->status === 'DELIVERED') { echo $result->otpCode; }
Errors
All non-2xx responses throw Verixo\Exception\VerixoException with
->status, and usually ->errorCode/->detail from the API's error body:
use Verixo\Exception\VerixoException; try { $vc->numbers->purchase(['serviceSlug' => 'whatsapp', 'countryCode' => 'NG']); } catch (VerixoException $e) { if ($e->status === 402) { echo "Insufficient wallet balance\n"; } }
Requirements
PHP 8.1+, with the curl and json extensions (both enabled by default in
most PHP installs).
Development
composer install composer exec phpstan analyse # static analysis, level 8 php examples/quickstart.php # requires VC_API_KEY env var, see file header
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-21