定制 rootscratch/sms 二次开发

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

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

rootscratch/sms

Composer 安装命令:

composer require rootscratch/sms

包简介

Android SMS Gateway transforms your Android smartphone into an SMS gateway. It is a lightweight application that enables you to send SMS messages programmatically via an API, making it ideal for integrating SMS functionality into your applications or services.

README 文档

README

Logo

📱 Android SMS Gateway (PHP)

Android SMS Gateway transforms your Android smartphone into an SMS gateway. It is a lightweight application that enables you to send SMS messages programmatically via an API, making it ideal for integrating SMS functionality into your applications or services.

🚀 Installation

To install the rootscratch/sms via Composer, run the following command:

composer require rootscratch/sms

📖 Usage/Examples

To use the Rootscratch SMS in your PHP project, include the Composer autoloader:

require_once __DIR__ . '/vendor/autoload.php';

use Rootscratch\SMS\Configuration;
$configuration = new Configuration();

// Set API Key
$configuration->setApiKey('your_api_key');

⚙️ Configuration Usage

/**
 * Configuration
 * 
 * Get Devices = getDevices()
 * Get Balance = getBalance()
 * 
 * Get Message By ID = getMessageByID($id) : if $id int = message id, if $id string = group id
 * 
 * Get Message By Status = getMessagesByStatus($status, $deviceID = null, $simID = null, $time = null, $endTimestamp = null)
 * Get messages "received" on SIM 1 of device ID 8 in last 24 hours = getMessagesByStatus("Received", 8, 0, time() - 86400)
 * 
 * Get USSD Request By ID = getUssdRequestByID($id)
 * Get USSD requests with request text "*150#" sent in last 24 hours. = getUssdRequests("*150#", null, null, time() - 86400)
 * 
 * Add a new contact to contacts list 1 or resubscribe the contact if it already exists. = addContact(1, "+11234567890", "Test", true);
 * Unsubscribe a contact using the mobile number. = unsubscribeContact(1, "+11234567890");
 * 
 */
echo json_encode($configuration->getDevices(), JSON_PRETTY_PRINT);

📤 Send Single SMS

use Rootscratch\SMS\Send;
$sendMessage = new Send();

$send_single = $sendMessage->sendSingleMessage('mobile_number', 'Message');

echo json_encode($send_single, JSON_PRETTY_PRINT);

📥 Send Bulk Message

$send_bulk = $sendMessage->sendMessages([
    [
        "number" => "6391234567890",
        "message" => "Message 1"
    ],
    [
        "number" => "6391234567891",
        "message" => "Message 2"
    ]
]);
echo json_encode($send_bulk, JSON_PRETTY_PRINT);

🖼️ Send MMS Sample

  • Use All Sims = sendMessages(messages = array, option = USE_ALL_SIMS)
  • Use All Devices = sendMessages(messages = array, option = USE_ALL_DEVICES)
  • Use Specified Devices = sendMessages(messages = array, option = USE_SPECIFIED, devices = array)
/**
 * Send MMS Sample
 * Use All Sims = sendMessages(messages = array, option = USE_ALL_SIMS)
 * Use All Devices = sendMessages(messages = array, option = USE_ALL_DEVICES)
 * Use Specified Devices = sendMessages(messages = array, option = USE_SPECIFIED, devices = array)
 */

$send_bulk_mms = $sendMessage->sendMessages([
    [
        "number" => "639123456789",
        "message" => "Test 1",
        "type" => "mms",
        "attachments" => 'https://sample.com/1.png'
    ],
    [
        "number" => "639123456789",
        "message" => "Test 2",
        "type" => "mms",
        "attachments" => 'https://sample.com/1.png'
    ]
]);
echo json_encode($send_bulk_mms, JSON_PRETTY_PRINT);

📇 Send Message To Contacts List

Send a message on schedule to contacts in contacts list with ID of 1.

$sendMessage->sendMessageToContactsList(1, "Test", null, null, strtotime("+2 minutes"));

Send a message to contacts in contacts list with ID of 1.

$send_contact_list = $sendMessage->sendMessageToContactsList(
    1,
    'Via Contact List!',
    Configuration::USE_SPECIFIED,
    [4]
);
echo json_encode($send_contact_list, JSON_PRETTY_PRINT);

📲 Send USSD Request

Send a USSD request using the default SIM of Device ID 1.

$send_ussd = $sendMessage->sendUssdRequest('*150#', 1);
echo json_encode($send_ussd, JSON_PRETTY_PRINT);

Send a USSD request using SIM in slot 1 of Device ID 1.

$send_ussd = $sendMessage->sendUssdRequest('*150#', 1, 0);
echo json_encode($send_ussd, JSON_PRETTY_PRINT);

Send a USSD request using SIM in slot 2 of Device ID 1.

$send_ussd = $sendMessage->sendUssdRequest('*150#', 1, 1);
echo json_encode($send_ussd, JSON_PRETTY_PRINT);

🔄 Resend SMS

/**
 * Resend SMS Sample
 * Resend Message By ID = resendMessageByID(id = int)
 * Resend Messages By Group ID = resendMessagesByGroupID(group_id = string, status = string)
 */

use Rootscratch\SMS\Resend;

$resend = new Resend();

$resend_by_id = $resend->resendMessagesByGroupID('MZ7QabWteHWfSkjkgX67acc67bcc2048.73874662', 'Failed');
echo json_encode($resend_by_id, JSON_PRETTY_PRINT);

🛠️ Support

For support, please email me at jaycee@rootscratch.com.

rootscratch/sms 适用场景与选型建议

rootscratch/sms 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16 次下载、GitHub Stars 达 5, 最近一次更新时间为 2025 年 02 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 rootscratch/sms 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rootscratch/sms 我们能提供哪些服务?
定制开发 / 二次开发

基于 rootscratch/sms 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 16
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-02-12