alagaccia / skebby
Skebby API
Installs: 66
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/alagaccia/skebby
Requires
- php: ^8.2|^8.3|^8.4
- laravel/framework: ^12.0
README
Package for using Skebby SMS gateway with Laravel projects.
Requirements
- PHP >= 7.0
- Laravel 8.x, 9.x, 10.x, or 11.x
Installation
Install this package using Composer:
composer require alagaccia/skebby
Publish Configuration (Optional)
The package will automatically register itself with Laravel. Optionally, you can publish the configuration file:
php artisan vendor:publish --tag=skebby-config
This will create config/skebby.php in your Laravel application.
Configuration
Add the following environment variables to your .env file:
SKEBBY_USER="your-skebby-username" SKEBBY_PWD="your-skebby-password" SKEBBY_ALIAS="your-skebby-alias" SKEBBY_QUALITY="TI"
Usage
Using the Facade
use Skebby; // Send SMS $result = Skebby::send('1234567890', 'Hello from Laravel!'); // Get account info $info = Skebby::getInfo(); // Get remaining credits $remaining = Skebby::getRemaining();
Using Dependency Injection
use AndreaLagaccia\Skebby\Skebby; class SmsController extends Controller { public function sendSms(Skebby $skebby) { $result = $skebby->send('1234567890', 'Hello from Laravel!'); return response()->json($result); } }
Direct Instantiation
use alagaccia\skebby\Skebby; $skebby = new Skebby(); $result = $skebby->send('1234567890', 'Hello World!');
Advanced Usage
Error Handling
The package includes comprehensive error handling with custom exceptions:
use alagaccia\skebby\Skebby; use alagaccia\skebby\Exceptions\SkebbyException; try { $skebby = new Skebby(); $result = $skebby->send('1234567890', 'Hello World!'); echo "SMS sent successfully!"; } catch (SkebbyException $e) { echo "SMS sending failed: " . $e->getMessage(); // Handle specific error codes if ($e->getCode() == 401) { echo "Authentication failed - check your credentials"; } }
Message Types
You can specify different message types when sending SMS:
use Skebby; // Send with specific message type $result = Skebby::send('1234567890', 'Hello!', Skebby::MESSAGE_CLASSIC_PLUS); // Send with campaign name for tracking $result = Skebby::send('1234567890', 'Hello!', null, 'Summer Campaign 2024'); // Send with both message type and campaign name $result = Skebby::send('1234567890', 'Hello!', Skebby::MESSAGE_CLASSIC_PLUS, 'Summer Campaign 2024'); // Available message types: // Skebby::MESSAGE_CLASSIC_PLUS ('GP') - Classic Plus // Skebby::MESSAGE_CLASSIC ('TI') - Classic (default) // Skebby::MESSAGE_BASIC ('SI') - Basic // Skebby::MESSAGE_EXPORT ('EE') - Export // Skebby::MESSAGE_ADVERTISING ('AD') - Advertising
Credit Management
Check remaining credits for different message types:
use Skebby; // Get remaining credits for current message type $remaining = Skebby::getRemaining(); // Get remaining credits for specific message type $remaining = Skebby::getRemaining(Skebby::MESSAGE_CLASSIC_PLUS); // Get all remaining credits $allCredits = Skebby::getAllRemainingCredits(); // Returns: ['GP' => 100, 'TI' => 200, 'SI' => 300, ...]
Authentication Cache
The package automatically caches authentication credentials for the duration of the request to improve performance:
use Skebby; // Clear authentication cache if needed Skebby::clearAuthCache();
Configuration Options
The configuration file supports the following options:
return [ 'SKEBBY_USER' => env('SKEBBY_USER'), 'SKEBBY_PWD' => env('SKEBBY_PWD'), 'SKEBBY_ALIAS' => env('SKEBBY_ALIAS'), 'SKEBBY_QUALITY' => env('SKEBBY_QUALITY', 'TI'), // Default message type ];
API Reference
Skebby Class Methods
send(string $phone, string $message, ?string $messageType = null, ?string $campaignName = null): ?arraygetInfo(): ?array- Get account informationgetRemaining(?string $messageType = null): int- Get remaining creditsgetAllRemainingCredits(): array- Get all remaining creditslogin(): array- Authenticate with APIclearAuthCache(): void- Clear authentication cache