1. Go to this page and download the library: Download sms-partners/php-sdk 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/ */
sms-partners / php-sdk example snippets
use SmsPartners\Client;
$client = new Client(apiKey: 'your-api-key');
$response = $client->send(
to: '+61412345678',
message: 'Your verification code is 123456.',
);
echo $response->id; // Message ID
echo $response->status; // "sending"
echo $response->to; // "+61412345678" (first recipient)
echo $response->body; // "Your verification code is 123456."
echo $response->creditsUsed; // 1
$response = $client->send(
to: '+61412345678',
message: 'Your order has shipped.',
from: 'MYCOMPANY',
);
$response = $client->send(
to: '+61412345678',
message: 'Your appointment is tomorrow at 10am.',
scheduledAt: new \DateTimeImmutable('+24 hours'),
);
echo $response->status; // "scheduled"
echo $response->scheduledAt // DateTimeImmutable
use SmsPartners\Exceptions\AuthenticationException;
use SmsPartners\Exceptions\InsufficientCreditsException;
use SmsPartners\Exceptions\ValidationException;
use SmsPartners\Exceptions\ApiException;
use SmsPartners\Exceptions\SmsPartnersException;
try {
$response = $client->send(to: '+61412345678', message: 'Hello!');
} catch (AuthenticationException $e) {
// Invalid or missing API key
} catch (InsufficientCreditsException $e) {
// Not enough credits — $e->balance and $e->
$client = new Client(
apiKey: 'your-api-key',
baseUrl: 'https://staging.smspartners.app',
);
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use SmsPartners\Client;
$mock = new MockHandler([
new Response(201, [], json_encode([
'data' => [
'id' => 1,
'status' => 'sending',
'body' => 'Hello!',
'from' => null,
'scheduled_at' => null,
'credits_used' => 1,
'created_at' => '2026-05-04T05:00:00+00:00',
'recipients' => [
['phone' => '+61412345678', 'status' => 'queued', 'delivered_at' => null, 'error_message' => null],
],
],
])),
]);
$guzzle = new GuzzleClient(['handler' => HandlerStack::create($mock)]);
$client = new Client(apiKey: 'test-key');
$reflection = new ReflectionProperty(Client::class, 'http');
$reflection->setAccessible(true);
$reflection->setValue($client, $guzzle);
$response = $client->send('+61412345678', 'Hello!');
assert($response->to === '+61412345678');
assert($response->creditsUsed === 1);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.