feridev/avanak
Composer 安装命令:
composer require feridev/avanak
包简介
A modern, well-tested, PSR-compliant PHP SDK for Avanak SMS API.
README 文档
README
This package provides an interface to connect with the Avanak API and supports features like voice call sending, OTP delivery, text-to-speech (TTS) generation, managing voice messages, and reporting.
📦 Package Structure
Avanak/
├── Contracts/
│ ├── AvanakClientInterface.php # Main interface for interacting with the Avanak API
│ └── HttpClientInterface.php # Abstraction layer for the HTTP client (e.g., Guzzle)
│
├── Http/
│ └── AvanakClient.php # Implementation of AvanakClientInterface
│
├── Services/
│ ├── AccountService.php # Fetch account status
│ ├── AudioService.php # Manage audio files (upload, delete, download, details)
│ ├── OtpService.php # Send OTP
│ └── TtsService.php # Send TTS call, generate TTS, quick send message
│
├── Support/
│ └── GuzzleHttpClient.php # Guzzle-based implementation of HttpClientInterface
🧰 Installation
If installing locally:
composer require feridev/avanak
Or, add to your composer.json:
"repositories": [ { "type": "path", "url": "./packages/avanak" } ], "require": { "feridev/avanak": "*" }
⚙️ Environment Setup
In your .env file, add the Avanak API token:
AVANAK_API_TOKEN=your_avanak_token
🧱 Usage
1. Define the client:
use Avanak\Support\GuzzleHttpClient; use Avanak\Http\AvanakClient; $httpClient = new GuzzleHttpClient(env('AVANAK_API_TOKEN')); $client = new AvanakClient($httpClient, 'https://api.avanak.ir');
2. Use the services:
Get account status:
use Avanak\Services\AccountService; $service = new AccountService($client); $status = $service->getAccountStatus();
Send OTP:
use Avanak\Services\OtpService; $service = new OtpService($client); $response = $service->sendOtp('your_password', 5, '09123456789');
Generate TTS:
use Avanak\Services\TtsService; $service = new TtsService($client); $response = $service->generateTTS('your_password', 'Sample text', 'Message Title');
Quick send with TTS:
$response = $service->quickSendWithTTS('your_password', 'Sample text', 'Title', '09123456789');
Send voice call using existing message ID:
$response = $service->quickSend('your_password', 1234, '09123456789');
Get quick send details:
$response = $service->getQuickSend('your_password', 4567);
Upload audio file:
use Avanak\Services\AudioService; $audioService = new AudioService($client); $base64Audio = base64_encode(file_get_contents('file.mp3')); $response = $audioService->uploadAudio($base64Audio, 'your_password', 'Message Title', true);
Download audio message:
$response = $audioService->downloadAudioMessage('message_id');
Get message details:
$response = $audioService->getMessageDetails('message_id');
Delete audio message:
$response = $audioService->deleteAudioMessage('message_id');
Get all messages:
$response = $audioService->getMessages();
Get quick send statistics:
$response = $audioService->getQuickSendStatistics('2024-01-01T00:00:00', '2024-12-31T23:59:59');
🧪 Testing
Automated tests have not been added yet. It is recommended to use Postman or curl for manual request validation.
🔒 Security
Ensure all sensitive data such as API tokens are stored in the .env file and never committed to version control.
🧑💻 Contributing
Contributions and pull requests to improve this package are welcome!
📜 License
This package is released under the MIT License.
feridev/avanak 适用场景与选型建议
feridev/avanak 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 05 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 feridev/avanak 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 feridev/avanak 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-04