定制 lessotp/sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固