This is a PHP client library for interfacing with the SMS Gateway for Android API.
- PHP 7.4 or higher
- A PSR-18 compatible HTTP client implementation
You can install the package via composer:
composer require capcom6/android-sms-gatewayHere is a simple example of how to send a message using the library:
<?php
require 'vendor/autoload.php';
use AndroidSmsGateway\Client;
use AndroidSmsGateway\Encryptor;
use AndroidSmsGateway\Domain\Message;
$login = 'your_login';
$password = 'your_password';
$client = new Client($login, $password);
// or
// $encryptor = new Encryptor('your_passphrase');
// $client = new Client($login, $password, Client::DEFAULT_URL, $httpClient, $encryptor);
$message = new Message('Your message text here.', ['+1234567890']);
try {
$messageState = $client->Send($message);
echo "Message sent with ID: " . $messageState->ID() . PHP_EOL;
} catch (Exception $e) {
echo "Error sending message: " . $e->getMessage() . PHP_EOL;
die(1);
}
try {
$messageState = $client->GetState($messageState->ID());
echo "Message state: " . $messageState->State() . PHP_EOL;
} catch (Exception $e) {
echo "Error getting message state: " . $e->getMessage() . PHP_EOL;
die(1);
}The Client is used for sending SMS messages in plain text, but can also be used for sending encrypted messages by providing an Encryptor.
The Client class has the following methods:
Send(Message $message): Send a new SMS message.GetState(string $id): Retrieve the state of a previously sent message by its ID.
Contributions are welcome! Please submit a pull request or create an issue for anything you'd like to add or change.
This library is open-sourced software licensed under the Apache-2.0 license.