taliffsss/unisms
Composer 安装命令:
composer require taliffsss/unisms
包简介
PHP client library for the UniSMS API (https://unismsapi.com)
README 文档
README
PHP client library for the UniSMS API — a powerful, reliable, and developer-friendly SMS API for the Philippines, supporting all major carriers (Globe, Smart, DITO, Sun, TNT).
Requirements
- PHP 8.0 or higher
- ext-curl
- ext-json
Installation
composer require taliffsss/unisms
Usage
Sending an SMS
use Taliffsss\UniSms\UniSms; $uniSms = new UniSms('your-secret-key'); $response = $uniSms->to('+639171234567') ->message('Hello world') ->from('MyBrand') // optional, defaults to "UniSMS" ->withMetadata(['order_id' => 12345]) // optional, echoed back by the API ->send(); // $response['message']['reference_id'], $response['message']['status'], ...
Checking a message's status
$status = $uniSms->get('msg_84e8b93b-6315-46af-a686');
Error handling
use Taliffsss\UniSms\Exceptions\ApiException; use Taliffsss\UniSms\Exceptions\TransportException; use Taliffsss\UniSms\Exceptions\UniSmsException; try { $uniSms->to('639171234567')->message('Hello world')->send(); } catch (ApiException $e) { // The API reached but returned a non-2xx response. $e->getStatusCode(); $e->getResponseBody(); } catch (TransportException $e) { // The request could not be completed (network/timeout/etc.). } catch (UniSmsException $e) { // Any other client-side validation error (e.g. missing recipient). }
Testing
composer install
composer test
License
The MIT License (MIT). See LICENSE for details.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-02