andriichuk / bsg-php-sdk
Framework-agnostic PHP SDK for the BSG World API
v0.1.0
2026-10-02 04:26 UTC
Requires
- php: ^8.3
- guzzlehttp/guzzle: ^7.9||^8.2
Requires (Dev)
- laravel/pint: ^1.14
- pestphp/pest: ^4.0
- phpstan/phpstan: ^2.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-02 04:46:33 UTC
README
Framework-agnostic PHP SDK for the BSG World REST API. It currently supports sending a single SMS and retrieving its delivery status.
Installation
composer require andriichuk/bsg-php-sdk
Send an SMS
use Andriichuk\Bsg\BsgClient; use Andriichuk\Bsg\Requests\SendSmsRequest; $client = new BsgClient('live_your_api_key'); $sent = $client->sendSms(new SendSmsRequest( msisdn: '+380991112233', originator: 'YourSender', body: 'You have been invited!', reference: 'invite42', )); $sent->id; $sent->reference; $sent->price; $sent->currency;
Optional request parameters are reference, validity, tariff, and twoWay. Phone numbers are normalized to digits before being sent.
Get SMS status
Use either the BSG message ID returned by sendSms() or your external reference:
$status = $client->getSmsStatus($sent->id); $sameStatus = $client->getSmsStatusByReference('invite42'); $status->status; // e.g. "delivered" $status->timeDr; // delivery-report time in UTC $status->msisdn; $status->price; $status->currency;
Both methods return SmsStatusResponse. BSG API failures throw BsgApiException, which exposes errorCode and errorDescription.
Development
composer test
composer analyse
composer format
License
The MIT License. See LICENSE for details.