定制 gosms-ge/sms-sdk 二次开发

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

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

gosms-ge/sms-sdk

Composer 安装命令:

composer require gosms-ge/sms-sdk

包简介

Official PHP SDK for GoSMS.ge SMS Gateway API

README 文档

README

Tests Latest Stable Version License

Official PHP SDK for the GoSMS.ge SMS Gateway API.

Requirements

  • PHP 7.4 or higher
  • A PSR-18 HTTP client (e.g., Guzzle, Symfony HttpClient)
  • A PSR-17 HTTP factory (e.g., nyholm/psr7, guzzlehttp/psr7)

Installation

composer require gosms-ge/sms-sdk

You also need a PSR-18 HTTP client. If you don't have one:

composer require guzzlehttp/guzzle

Or with Symfony:

composer require symfony/http-client nyholm/psr7

Quick Start

<?php

use GoSmsGe\SmsSDK\GoSmsClient;

$client = new GoSmsClient('your-api-key');

// Send SMS
$response = $client->sendSms('MYBRAND', '995555123456', 'Hello!');
echo $response->messageId; // 12345
echo $response->balance;   // 4999

Usage

Send SMS

$response = $client->sendSms('MYBRAND', '995555123456', 'Hello!');

// With urgent flag
$response = $client->sendSms('MYBRAND', '995555123456', 'Urgent!', true);

$response->success;       // bool
$response->messageId;     // int
$response->from;          // string
$response->to;            // string
$response->text;          // string
$response->sendAt;        // string (ISO 8601)
$response->balance;       // int
$response->encode;        // "default" or "Unicode"
$response->segment;       // int
$response->smsCharacters; // int

Send Bulk SMS

$response = $client->sendBulkSms(
    'MYBRAND',
    ['995555111111', '995555222222', '995555333333'],
    'Sale today!'
);

$response->totalCount;   // 3
$response->successCount; // 3
$response->failedCount;  // 0

foreach ($response->messages as $msg) {
    echo $msg->messageId . ' -> ' . $msg->to;
    if (!$msg->success) {
        echo ' FAILED: ' . $msg->error;
    }
}

Check SMS Status

$response = $client->checkSms(12345);

$response->status; // "IN_PROGRESS", "DELIVERED", "REJECTED", "EXPIRED", "QUEUE", "ENROUTE"

Check Balance

$response = $client->getBalance();

$response->balance; // 5000

Send OTP

$response = $client->sendOtp('995555123456');

$response->hash;    // "abc123..." — save this for verification
$response->balance; // 4999

// Rate limit info
if ($response->rateLimitInfo) {
    echo $response->rateLimitInfo->remaining; // 9
    echo $response->rateLimitInfo->limit;     // 10
}

Verify OTP

$response = $client->verifyOtp('995555123456', $hash, '1234');

if ($response->verify) {
    echo 'OTP verified!';
} else {
    echo 'Wrong code';
}

// Rate limit info
if ($response->rateLimitInfo) {
    echo $response->rateLimitInfo->remaining; // 8
}

Note: A wrong OTP code returns verify: false without throwing an exception. Exceptions are thrown only for expired OTPs, already-used OTPs, and locked accounts.

Create Sender

$response = $client->createSender('NewBrand');

$response->success; // true

Error Handling

All API errors throw specific exceptions that extend ApiException:

use GoSmsGe\SmsSDK\Exception\ApiException;
use GoSmsGe\SmsSDK\Exception\InsufficientBalanceException;
use GoSmsGe\SmsSDK\Exception\InvalidPhoneException;
use GoSmsGe\SmsSDK\Exception\NetworkException;

try {
    $client->sendSms('MYBRAND', '995555123456', 'Hello!');
} catch (InsufficientBalanceException $e) {
    // Handle low balance
} catch (InvalidPhoneException $e) {
    // Handle bad phone number
} catch (ApiException $e) {
    // Catch-all for any API error
    echo $e->getErrorCode();    // int (100-113)
    echo $e->getErrorMessage(); // string
} catch (NetworkException $e) {
    // Transport failure or invalid JSON response
}

Rate Limit Errors

When OTP rate limits are exceeded, the exception includes retryAfter (seconds until lockout expires):

use GoSmsGe\SmsSDK\Exception\TooManyRequestsException;
use GoSmsGe\SmsSDK\Exception\AccountLockedException;

try {
    $response = $client->sendOtp('995555123456');
} catch (TooManyRequestsException $e) {
    echo 'Too many attempts. Retry after ' . $e->getRetryAfter() . 's';
} catch (AccountLockedException $e) {
    echo 'Account locked. Retry after ' . $e->getRetryAfter() . 's';
}

Error Code Reference

Code Exception Description
100 InvalidApiKeyException Invalid or missing API key
101 InvalidSenderException Invalid sender name
102 InsufficientBalanceException Not enough SMS balance
103 InvalidParametersException Invalid parameters or message too long
104 MessageNotFoundException Message ID not found
105 InvalidPhoneException Invalid phone number format
106 OtpFailedException Failed to generate/send OTP
107 SenderExistsException Sender name already exists
108 NotConfiguredException API token not configured for this operation
109 TooManyRequestsException Too many OTP requests (rate limited)
110 AccountLockedException Account locked (too many failed attempts)
111 OtpExpiredException OTP code expired
112 OtpAlreadyUsedException OTP code already used
113 InvalidNoSmsNumberException Invalid noSmsNumber parameter

Custom HTTP Client

The SDK auto-detects your installed PSR-18 HTTP client. To provide a custom one:

use GoSmsGe\SmsSDK\GoSmsClient;
use GuzzleHttp\Client as Guzzle;

$guzzle = new Guzzle(['timeout' => 10]);

$client = new GoSmsClient(
    'your-api-key',
    'https://api.gosms.ge',
    $guzzle
);

Custom Base URL

$client = new GoSmsClient('your-api-key', 'https://your-custom-endpoint.com');

Laravel Integration

// In AppServiceProvider::register()
$this->app->singleton(GoSmsClient::class, function () {
    return new GoSmsClient(config('services.gosms.api_key'));
});

// In your controller
public function send(GoSmsClient $gosms)
{
    $gosms->sendSms('MYBRAND', $request->phone, 'Your code is 1234');
}

Phone Number Format

The API accepts Georgian mobile numbers in two formats:

  • 9 digits starting with 5: 555123456
  • 12 digits with country code: 995555123456

SMS Limits

  • GSM-7 (default): 160 chars per segment, max 918 chars (6 segments)
  • Unicode: 70 chars per segment, max 402 chars (6 segments)
  • Encoding is detected automatically by the API

License

MIT

gosms-ge/sms-sdk 适用场景与选型建议

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

它主要适用于以下技术方向: 「api」 「sms」 「sdk」 「otp」 「georgia」 「gosms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-22