1. Go to this page and download the library: Download calisero/calisero-php 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/ */
alisero\Sms\SmsClient;
use Calisero\Sms\Dto\CreateMessageRequest;
use Calisero\Sms\Exceptions\NotFoundException;
$client = SmsClient::create('your-api-key-here');
// Check if user is opted out first
try {
$client->optOuts()->get($phoneNumber);
echo "User is opted out, skipping message\n";
} catch (NotFoundException $e) {
// User is not opted out, safe to send
$request = new CreateMessageRequest(
recipient: $phoneNumber,
body: "Special offer! Get 20% off with code SAVE20. Reply STOP to opt out.",
sender: 'YourBrand'
);
$response = $client->messages()->create($request);
echo "Marketing message sent!\n";
}
alisero\Sms\SmsClient;
use Calisero\Sms\Dto\CreateMessageRequest;
$client = SmsClient::create('your-api-key-here');
$request = new CreateMessageRequest(
recipient: '+40742***350',
body: 'Your verification code is: 123456',
visibleBody: 'Your verification code is: ******', // For logs/display
validity: 24, // 24 hours validity
scheduleAt: '2024-12-25 10:00:00', // Schedule for later
callbackUrl: 'https://yoursite.com/webhook', // Delivery reports
sender: 'Calisero' // Custom sender
);
$response = $client->messages()->create($request);
echo "Advanced message created with ID: " . $response->getData()->getId() . "\n";
alisero\Sms\SmsClient;
// Simple client creation - all you need
$client = SmsClient::create('your-api-key-here');
alisero\Sms\Contracts\IdempotencyKeyProviderInterface;
use Calisero\Sms\SmsClient;
class CustomIdempotencyProvider implements IdempotencyKeyProviderInterface
{
public function generate(): string
{
return 'custom-' . uniqid() . '-' . time();
}
}
// Note: This
// In your tests, you can mock the HTTP client
use PHPUnit\Framework\TestCase;
use Calisero\Sms\SmsClient;
use Calisero\Sms\Dto\CreateMessageRequest;
use Calisero\Sms\Contracts\HttpClientInterface;
class YourSmsTest extends TestCase
{
public function testSendMessage()
{
$mockClient = $this->createMock(HttpClientInterface::class);
// Set up your mock expectations for testing
// Use the library's built-in interfaces for clean testing
$client = SmsClient::create('test-token');
// ... your test implementation
}
}
// ... other fields
}
}
bash
composer
bash
git clone https://github.com/calisero/calisero-php.git
cd calisero-php
composer install
bash
php examples/messages/send_simple_sms.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.