1. Go to this page and download the library: Download capcom6/android-sms-gateway library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Initialize client with Basic authentication
$client = new Client('your_login', 'your_password');
use AndroidSmsGateway\Client;
use AndroidSmsGateway\Domain\TokenRequest;
// First, create a client with Basic authentication to generate a token
$basicClient = new Client('your_login', 'your_password');
// Create a token request with specific scopes and TTL
$tokenRequest = new TokenRequest(
['messages:send', 'messages:read'], // Scopes for permissions
3600 // Token TTL in seconds (optional)
);
// Generate the token
$tokenResponse = $basicClient->GenerateToken($tokenRequest);
$jwtToken = $tokenResponse->AccessToken();
echo "Token generated! Expires at: " . $tokenResponse->ExpiresAt() . PHP_EOL;
// Initialize client with JWT authentication
$jwtClient = new Client(null, $jwtToken);
// Now use the client as usual
$message = (new MessageBuilder('Your message text here.', ['+1234567890']))->build();
$messageState = $jwtClient->SendMessage($message);
// Revoke a token using its ID (jti)
$basicClient->RevokeToken($tokenResponse->ID());
echo "Token revoked successfully!" . PHP_EOL;
$clientBasic = 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
);
$clientJWT = new Client(
null, // Set login to null for JWT
string $jwtToken, // JWT token as the second parameter
string $serverUrl = 'https://api.sms-gate.app/3rdparty/v1',
?\Psr\Http\Client\ClientInterface $httpClient = null,
?\AndroidSmsGateway\Encryptor $encryptor = null
);
use AndroidSmsGateway\Encryptor;
// Initialize client with encryption
$encryptor = new Encryptor('your-secret-passphrase');
$client = new Client($login, $password, Client::DEFAULT_URL, null, $encryptor);
bash
git clone https://github.com/android-sms-gateway/client-php.git
cd client-php
composer install
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.