pahappa-limited/comms-sdk
Composer 安装命令:
composer require pahappa-limited/comms-sdk
包简介
This is the PHP version of the Comms SDK - which will help PHP software to communicate with the Communications platform bulk messaging servce by Pahappa Limited
README 文档
README
A PHP implementation of the CommsSDK for sending SMS and managing communications, following the same patterns as the Python, Ruby, and other language reference implementations.
Version: 1.0.1
Features
- Consistent API across all supported languages
- Authenticate with username and API key
- Send SMS to one or more recipients
- Optional sender ID and message priority
- Check account balance
- Comprehensive error handling
Installation
Install via Composer:
composer require pahappa/comms-sdk
Or add to your composer.json:
{
"require": {
"pahappa/comms-sdk": "1.0.1"
}
}
Usage
Basic Authentication
require_once 'vendor/autoload.php'; use CommsSDK\V1\CommsSDK; // Authenticate with your username and API key $sdk = CommsSDK::authenticate('your_username', 'your_api_key');
Sending SMS
// Send SMS to a single number $success = $sdk->sendSMS('256712345678', 'Hello from PHP!'); // Send SMS to multiple numbers $success = $sdk->sendSMS(['256712345678', '256787654321'], 'Hello to all!'); // Send SMS with custom sender ID and priority $success = $sdk->sendSMS( ['256712345678'], 'Hello!', 'MyApp', MessagePriority::HIGH ); // Get full API response $response = $sdk->querySendSMS( ['256712345678'], 'Hello!', 'MyApp', MessagePriority::HIGHEST );
Checking Balance
// Get balance as a float $balance = $sdk->getBalance(); echo "Balance: $balance\n"; // Get full balance response $response = $sdk->queryBalance(); echo "Status: {$response->status}\n"; echo "Balance: {$response->balance}\n"; echo "Currency: {$response->currency}\n";
Configuration
// Use sandbox environment CommsSDK::useSandBox(); // Use live server (default) CommsSDK::useLiveServer(); // Set custom sender ID $sdk = $sdk->withSenderId('MyCustomSender');
API Reference
CommsSDK
Static Methods
CommsSDK::authenticate($userName, $apiKey): CommsSDK- Authenticate and return SDK instance.
CommsSDK::useSandBox()- Switch to sandbox environment.
CommsSDK::useLiveServer()- Switch to live environment.
Instance Methods
withSenderId($senderId): CommsSDK- Set sender ID, returns self for chaining.
sendSMS($numbers, $message, $senderId = null, $priority = MessagePriority::HIGHEST): bool- Send SMS, returns boolean.
querySendSMS($numbers, $message, $senderId, $priority): ?ApiResponse- Send SMS, returns full ApiResponse.
getBalance(): ?float- Get account balance as float.
queryBalance(): ?ApiResponse- Get full balance response as ApiResponse.
isAuthenticated(): bool- Returns authentication status.
getApiKey()- The API key used for authentication.
getUserName()- The username used for authentication.
getSenderId()- Current sender ID.
Models
MessagePriority
MessagePriority::HIGHEST- Priority "0"MessagePriority::HIGH- Priority "1"MessagePriority::MEDIUM- Priority "2"MessagePriority::LOW- Priority "3"MessagePriority::LOWEST- Priority "4"
ApiResponse
status- Response status ("OK" or "Failed")message- Response messagecost- Message costcurrency- Currency codemsgFollowUpUniqueCode- Unique tracking codebalance- Account balance
Error Handling
The SDK throws exceptions for authentication and validation errors:
try { $sdk = CommsSDK::authenticate('', ''); // Empty credentials } catch (InvalidArgumentException $e) { echo "Authentication error: " . $e->getMessage(); } try { $sdk->sendSMS([], ''); // Empty numbers and message } catch (InvalidArgumentException $e) { echo "Validation error: " . $e->getMessage(); }
Contributing
Bug reports and pull requests are welcome on GitHub.
License
The SDK is available as open source under the terms of the MIT License.
pahappa-limited/comms-sdk 适用场景与选型建议
pahappa-limited/comms-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 pahappa-limited/comms-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pahappa-limited/comms-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-17