Search by

capcom6 / android-sms-gateway

capcom6

Provides access to Android SMS Gateway API

Package info

github.com/android-sms-gateway/client-php

pkg:composer/capcom6/android-sms-gateway

Statistics

Installs: 22 103

Dependents: 1

Suggesters: 0

Stars: 35

Open Issues: 2

v2.6.1 2026-09-23 03:42 UTC

README

Contributors Forks Stars Issues License Packagist Version

A modern PHP client for the SMSGate API: send SMS messages and manage devices, webhooks, settings, and JWT tokens through your Android devices. PSR-18/PSR-17 compatible with any HTTP client via php-http/discovery. See the client libraries overview for the full ecosystem.

📖 About

capcom6/android-sms-gateway is a type-safe PHP library for the SMSGate 3rd-party API. It covers messages (send, state, listing, cancellation), inbox refresh with individual or batch webhook delivery and attachment download, devices, webhooks, settings, logs, health checks, and the JWT token lifecycle, with a fluent MessageBuilder for message construction and an optional Encryptor for end-to-end encryption. Works with any PSR-18 HTTP client (Guzzle, curl, or others) and PHP 7.4+.

📚 Table of Contents

⭐ Features

  • Fluent MessageBuilder for messages and SettingsBuilder for settings
  • Messages: send, state, listing, and cancellation
  • PSR-18 HTTP client and PSR-17 factories, auto-discovered
  • Basic and JWT authentication with token generation and revocation
  • Inbox refresh with individual or batch webhook delivery and MMS attachment download
  • Webhooks (single and batch events), devices, settings, logs, and health checks
  • Optional end-to-end encryption via Encryptor
  • Structured HttpException error handling

📦 Installation

composer require capcom6/android-sms-gateway

Requires PHP 7.4+ and a PSR-18 HTTP client implementation (e.g. Guzzle, php-http/curl-client).

🔑 Authentication

Two methods are supported: Basic authentication with account credentials, and JWT bearer tokens with scoped permissions. JWT is recommended for production.

Basic Authentication

// Basic authentication with account credentials
$client = new Client('your_login', 'your_password');

JWT Authentication

use AndroidSmsGateway\Domain\TokenRequest;

$basicClient = new Client('your_login', 'your_password');

$token = $basicClient->GenerateToken(
    new TokenRequest(['messages:send', 'messages:read'], 3600)
);

$jwtClient = new Client(null, $token->AccessToken());

🚀 Quickstart

<?php

require 'vendor/autoload.php';

use AndroidSmsGateway\Client;
use AndroidSmsGateway\Domain\MessageBuilder;

$client = new Client('your_login', 'your_password');

$message = (new MessageBuilder('Hello from PHP', ['+15550100']))
    ->setWithDeliveryReport(true)
    ->build();

$state = $client->SendMessage($message);
echo 'Message ID: ' . $state->ID() . PHP_EOL;

💻 Usage

Beyond sending, the client covers message listing and cancellation, inbox listing and refresh, device management, health checks, logs, settings (get, patch, replace), webhooks, and token lifecycle. See src/Client.php for the complete method list with signatures and src/Domain for the domain models.

⚙️ Configuration

The Client constructor accepts the following parameters:

Parameter Required Description
$login No Account login for Basic authentication
$password Yes Account password (Basic) or a JWT token (Bearer)
$serverUrl No API base URL; defaults to https://api.sms-gate.app/3rdparty/v1
$client No PSR-18 HTTP client; auto-discovered via php-http/discovery when omitted
$encryptor No Optional Encryptor for end-to-end encryption

When $login is set, Basic authentication is used. When only $password is provided, it is sent as a Bearer JWT token.

📖 API Reference

🤝 Contributing

Contributions are welcome. Open an issue to discuss major changes before submitting a pull request; PRs target the master branch.

📄 License

Distributed under the Apache License 2.0. See LICENSE.