定制 swiftsmsgh/swiftsmsgh-api-sdk 二次开发

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

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

swiftsmsgh/swiftsmsgh-api-sdk

Composer 安装命令:

composer require swiftsmsgh/swiftsmsgh-api-sdk

包简介

PHP SDK for the Swiftsms-GH Bulk SMS API

README 文档

README

PHP Version License Packagist

The Swiftsms-GH PHP SDK provides a suitable approach to the Swiftsms-GH API from applications written in PHP. It includes pre-defined set of classes and functions for API resource that initialize themselves from API responses.

The library provides other features. For Example:

  1. Easy configuration path for fast setup and use
  2. Helpers for pagination.

You can sign up for an Swiftsms-GH account at swiftsmsgh.com

Table of Contents

Prerequisites

PHP ^8.0 and later

Installation

Via Composer

$ composer require swiftsmsgh/swiftsmsgh-api-sdk

Via Git Bash

git clone git@github.com:supreme-majesty/swiftsmsgh-api-sdk.git

Documentation

Please see https://swiftsmsgh.com/developer for up-to-date documentation

Usage

Step 1:

If you install the Swiftsms-GH PHP SDK via Git Clone then load the Swiftsms-GH PHP API class file and use namespace.

require_once '/path/to/src/Swiftsmsgh.php';
use Swiftsms\Swiftsmsgh;

If you install Swiftsms-GH PHP SDK via Composer require the autoload.php file in the index.php of your project or whatever file you need to use Swiftsms-GH PHP API classes.

require __DIR__ . '/vendor/autoload.php';
use Swiftsms\Swiftsmsgh;

The Swiftsms-GH PHP SDK endpoints are RESTful, and consume and return JSON. All Http endpoints requires an API Key in the request header.

For more information on how to get an API Key visit here to copy or generate new key for authorization.

Exception Handling

The SDK throws Swiftsms\SwiftsmsException when an API or network error occurs.

try {
    $response = $client->send_sms($recipients, $message);
} catch (Swiftsms\SwiftsmsException $e) {
    echo "Error: " . $e->getMessage();
}

HTTP Endpoints

Step 2:

Instantiate the SwiftsmsghSMSSDKAPI

$api_token = "Enter Your API Token here";

$sender_id = "Enter your approved Sender ID here";

$client = new Swiftsms\Swiftsmsgh($api_token, $sender_id);

Send Messages

1. Send SMS

$recipients = "233538000000,233540000000";
$message = "This is a test message";

$response = $client->send_sms($recipients, $message);

2. Schedule Message & Custom Sender ID

You can pass an optional $options array to any sending method.

$options = [
    'schedule_time' => '2025-12-25 08:00', // Format: Y-m-d H:i
    'sender_id'     => 'MyAlert'           // Override default Sender ID
];

$client->send_sms($recipients, $message, $options);

3. Send Voice Call

// gender: 'male' or 'female'
// language: 'en-gb', 'en-us', etc.
$client->send_voice($recipients, "Wake up!", "female", "en-gb");

4. Send MMS

$mediaUrl = "https://example.com/image.jpg";
$client->send_mms($recipients, "Here is the photo", $mediaUrl);

5. Send OTP

$client->send_otp($recipients, "Your verification code is 1234");

6. Send WhatsApp

$client->send_whatsapp($recipients, "Hello from WhatsApp API");

7. Send Viber

$client->send_viber($recipients, "Hello from Viber API");

Contacts Management

Contact Groups

// Get all contact groups
$groups = $client->all_contact_groups();

// View a specific contact group
$group = $client->view_contact_group($group_id);

// Create a new contact group
$client->create_contact_group($phones, $groupName);

// Update a contact group
$client->update_contact_group($phones, $groupName);

// Delete a contact group
$client->delete_contact_group($group_id);

Individual Contacts

// Get all contacts in a group
$contacts = $client->all_contacts_in_group($group_id);

// View a specific contact
$contact = $client->view_contact($group_id, $uid);

// Create a new contact
$client->create_contact($phones, $message);

// Update a contact
$client->update_contact($phones, $message);

// Delete a contact
$client->delete_contact($group_id, $uid);

Check SMS Credit Balance

$get_credit_balance = $client->check_balance();

View Profile

$get_profile = $client->profile();

Status Codes

Status Message
ok Successfully Send
100 Bad gateway requested
101 Wrong action
102 Authentication failed
103 Invalid phone number
104 Phone coverage not active
105 Insufficient balance
106 Invalid Sender ID
107 Invalid SMS Type
108 SMS Gateway not active
109 Invalid Schedule Time
110 Media url required
111 SMS contain spam word. Wait for approval

Response Examples

Successful SMS Send

{
    "status": "ok",
    "message": "Successfully Send",
    "data": {
        "uid": "abc123xyz",
        "to": "233538000000",
        "message": "This is a test message",
        "status": "delivered"
    }
}

Balance Check

{
    "status": "ok",
    "data": {
        "remaining_balance": 150.5,
        "currency": "GHS"
    }
}

Error Response

{
    "status": "error",
    "code": 102,
    "message": "Authentication failed"
}

Contributing

Please see CONTRIBUTING.md for details on how to contribute to this project.

Changelog

Please see CHANGELOG.md for a list of changes.

License

This project is licensed under the MIT License - see the LICENSE file for details.

swiftsmsgh/swiftsmsgh-api-sdk 适用场景与选型建议

swiftsmsgh/swiftsmsgh-api-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 54 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 swiftsmsgh/swiftsmsgh-api-sdk 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 54
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 12
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-09