capcom6 / android-sms-gateway
Provides access to Android SMS Gateway API
Installs: 2 674
Dependents: 1
Suggesters: 0
Security: 0
Stars: 19
Watchers: 2
Forks: 8
Open Issues: 0
Requires
- php: >=7.4
- php-http/discovery: ^1.17
- psr/http-client-implementation: ^1.0
Requires (Dev)
- laminas/laminas-diactoros: ^2.17
- php-http/curl-client: ^2.2
- php-http/message: ^1.0
- php-http/mock-client: ^1.0
- phpstan/phpstan: ^1.5 || ^2.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2025-06-04 01:38:49 UTC
README
A modern PHP client for seamless integration with the SMS Gateway for Android API. Send SMS messages, manage devices, and configure webhooks through your PHP applications with this intuitive library.
π Table of Contents
- π± SMS Gateway for Androidβ’ PHP API Client
β¨ Features
- Builder Pattern: Fluent interface for message and settings configuration
- PSR Standards: Compatible with any PSR-18 HTTP client
- Comprehensive API: Access to all SMS Gateway endpoints
- Error Handling: Structured exception management
- Type Safety: Strict typing throughout the codebase
- Encryption Support: End-to-end message encryption
βοΈ Prerequisites
π¦ Installation
composer require capcom6/android-sms-gateway
π Quickstart
Sending an SMS
<?php require 'vendor/autoload.php'; use AndroidSmsGateway\Client; use AndroidSmsGateway\Domain\MessageBuilder; // Initialize client with credentials $client = new Client('your_login', 'your_password'); // Build message with fluent interface $message = (new MessageBuilder('Your message text here.', ['+1234567890'])) ->setTtl(3600) // Message time-to-live in seconds ->setSimNumber(1) // Use SIM slot 1 ->setWithDeliveryReport(true) // Request delivery report ->setPriority(100) // Higher priority message ->build(); // Send message try { $messageState = $client->SendMessage($message); echo "β Message sent! ID: " . $messageState->ID() . PHP_EOL; // Check status after delay sleep(5); $updatedState = $client->GetMessageState($messageState->ID()); echo "π Message status: " . $updatedState->State() . PHP_EOL; } catch (\Exception $e) { echo "β Error: " . $e->getMessage() . PHP_EOL; exit(1); }
Managing Devices
// List registered devices $devices = $client->ListDevices(); echo "π± Registered devices: " . count($devices) . PHP_EOL; // Remove a device try { $client->RemoveDevice('device-id-123'); echo "ποΈ Device removed successfully" . PHP_EOL; } catch (\Exception $e) { echo "β Device removal failed: " . $e->getMessage() . PHP_EOL; }
π Full API Reference
Client Initialization
$client = new Client( string $login, string $password, string $serverUrl = 'https://api.sms-gate.app/3rdparty/v1', ?\Psr\Http\Client\ClientInterface $httpClient = null, ?\AndroidSmsGateway\Encryptor $encryptor = null );
Core Methods
Category | Method | Description |
---|---|---|
Messages | SendMessage(Message $message) |
Send SMS message |
GetMessageState(string $id) |
Get message status by ID | |
RequestInboxExport(MessagesExportRequest $request) |
Request inbox export via webhooks | |
Devices | ListDevices() |
List registered devices |
RemoveDevice(string $id) |
Remove device by ID | |
System | HealthCheck() |
Check API health status |
GetLogs(?string $from, ?string $to) |
Retrieve system logs | |
Settings | GetSettings() |
Get account settings |
PatchSettings(Settings $settings) |
Partially update account settings | |
ReplaceSettings(Settings $settings) |
Replace account settings | |
Webhooks | ListWebhooks() |
List registered webhooks |
RegisterWebhook(Webhook $webhook) |
Register new webhook | |
DeleteWebhook(string $id) |
Delete webhook by ID |
Builder Methods
// Message Builder $message = (new MessageBuilder(string $text, array $recipients)) ->setTtl(int $seconds) ->setSimNumber(int $simSlot) ->setWithDeliveryReport(bool $enable) ->setPriority(int $value) ->build();
π Security Notes
Best Practices
- Never store credentials in code - Use environment variables:
$login = getenv('SMS_GATEWAY_LOGIN'); $password = getenv('SMS_GATEWAY_PASSWORD');
- Use HTTPS - Ensure all API traffic is encrypted
- Validate inputs - Sanitize phone numbers and message content
- Rotate credentials - Regularly update your API credentials
Encryption Support
use AndroidSmsGateway\Encryptor; // Initialize client with encryption $encryptor = new Encryptor('your-secret-passphrase'); $client = new Client($login, $password, Client::DEFAULT_URL, null, $encryptor);
π₯ Contributing
We welcome contributions! Please follow these steps:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Development Setup
git clone https://github.com/android-sms-gateway/client-php.git
cd client-php
composer install
π License
This library is open-sourced software licensed under the Apache-2.0 license.
Note: Android is a trademark of Google LLC. This project is not affiliated with or endorsed by Google.