codexoft/mobilesasa-sdk
Composer 安装命令:
composer require codexoft/mobilesasa-sdk
包简介
The Mobilesasa SDK is a PHP library that provides seamless integration with the Mobilesasa API for sending SMS messages, managing contact groups, and conducting mobile surveys. This SDK supports various messaging features including single SMS, bulk SMS, personalized bulk messaging, and delivery stat
README 文档
README
The Mobilesasa SDK is a PHP library that provides seamless integration with the Mobilesasa API for sending SMS messages, managing contact groups, and conducting mobile surveys. This SDK supports various messaging features including single SMS, bulk SMS, personalized bulk messaging, and delivery status tracking.
Table of Contents
Installation
To install the Mobilesasa SDK, use Composer:
composer require codexoft/mobilesasa-sdk
Configuration
Initialize the SDK with your credentials:
use Codexoft\MobilesasaSDK\Mobilesasa; $config = [ 'senderId' => 'YOUR_SENDER_ID', 'apiKey' => 'YOUR_API_KEY', 'mobileServeyKey' => 'YOUR_SURVEY_KEY', 'showBalance' => true, // Optional: Show balance in responses 'shortCode' => 'YOUR_SHORT_CODE' // Optional: For short code messaging ]; $mobilesasa = new Mobilesasa($config);
Basic Usage
Sending a Single SMS
$response = $mobilesasa->sendSMS('0712345678', 'Hello World!');
Sending Bulk SMS
$phoneNumbers = ['0712345678', '0723456789']; $response = $mobilesasa->sendBulkSms($phoneNumbers, 'Hello everyone!');
Features
Message Management
Phone Number Details
Get information about a phone number, including the network provider:
$details = $mobilesasa->phoneNumberDetails('0712345678');
Calculate Message Length
Analyze message length and SMS parts:
$messageInfo = $mobilesasa->calculateMessageLength('Your message here');
Check Delivery Status
Track the delivery status of sent messages:
$status = $mobilesasa->smsDeliveryStatus('message_id');
Personalized Bulk SMS
Send different messages to different recipients:
$messageBody = [ [ 'phone' => '0712345678', 'message' => 'Hello John!' ], [ 'phone' => '0723456789', 'message' => 'Hello Jane!' ] ]; $response = $mobilesasa->sendPersonalizedBulkSms($messageBody);
Contact Groups
List Groups
$groups = $mobilesasa->smsGroups();
Add Contact to Group
$contactDetails = [ 'name' => 'John Doe', 'phone' => '0712345678', 'email' => 'john@example.com' // Optional ]; $response = $mobilesasa->addToGroup('GROUP_CODE', $contactDetails);
Remove Contact from Group
$response = $mobilesasa->deleteFromGroup('GROUP_CODE', '0712345678');
Anniversary Groups
List Anniversary Groups
$groups = $mobilesasa->anniversaryGroups();
Add Contact to Anniversary Group
$contactDetails = [ 'name' => 'John Doe', 'phone' => '0712345678', 'date' => '2024-01-01' ]; $response = $mobilesasa->addToAnniversaryGroup('GROUP_CODE', $contactDetails);
Remove Contact from Anniversary Group
$response = $mobilesasa->deleteFromAnniversaryGroup('GROUP_CODE', '0712345678');
Mobile Surveys
Send mobile surveys to contacts:
$contactDetails = [ 'name' => 'John Doe', 'phone' => '0712345678' ]; // Send immediately $response = $mobilesasa->mobileServey('SURVEY_ID', $contactDetails); // Schedule for later $response = $mobilesasa->mobileServey( 'SURVEY_ID', $contactDetails, false, '2024-01-20 10:00:00', '2024-01-20 18:00:00' );
API Reference
Phone Number Format Support
The SDK automatically handles various phone number formats:
- 9 digits (e.g., '712345678')
- 10 digits with leading zero (e.g., '0712345678')
- 12 digits with country code (e.g., '254712345678')
Response Format
Most methods return an array containing:
status: Boolean indicating successresponseCode: API response codemessage: Response message- Additional data specific to the operation
balance: Account balance (if showBalance is true in config)
Error Handling
The SDK uses the MobilesasaException class for error handling:
try { $response = $mobilesasa->sendSMS('0712345678', 'Hello World!'); } catch (MobilesasaException $e) { echo 'Error: ' . $e->getMessage(); echo 'Status Code: ' . $e->getStatusCode(); echo 'Response: ' . print_r($e->getResponse(), true); }
Common exceptions include:
- Invalid phone number format
- Missing required parameters
- API authentication errors
- Network connectivity issues
For detailed API documentation and error codes, please visit the Mobilesasa API Documentation.
codexoft/mobilesasa-sdk 适用场景与选型建议
codexoft/mobilesasa-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「sms」 「sdk」 「bulk-sms」 「mobilesasa」 「mobile-surveys」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 codexoft/mobilesasa-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 codexoft/mobilesasa-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 codexoft/mobilesasa-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Extensible library for building notifications and sending them via different delivery channels.
yii2-sms expand
A fork of simplesoftwareio/simple-sms with Verimor driver.
Aakash Sms Provider Api Wrapper
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-18