capcom6 / android-sms-gateway
Provides access to Android SMS Gateway API
Installs: 1 435
Dependents: 1
Suggesters: 0
Security: 0
Stars: 12
Watchers: 2
Forks: 4
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
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-11-18 22:34:00 UTC
README
This is a PHP client library for interfacing with the SMS Gateway for Android API.
Requirements
- PHP 7.4 or higher
- A PSR-18 compatible HTTP client implementation
Installation
You can install the package via composer:
composer require capcom6/android-sms-gateway
Usage
Here 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); }
Client
The Client
is used for sending SMS messages in plain text, but can also be used for sending encrypted messages by providing an Encryptor
.
Methods
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.
Contributing
Contributions are welcome! Please submit a pull request or create an issue for anything you'd like to add or change.
License
This library is open-sourced software licensed under the Apache-2.0 license.