Search by

andriichuk / bsg-php-sdk

andriichuk

Framework-agnostic PHP SDK for the BSG World API

Package info

github.com/andriichuk/bsg-php-sdk

pkg:composer/andriichuk/bsg-php-sdk

Statistics

Installs: 50

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-10-02 04:26 UTC

This package is auto-updated.

Last update: 2026-10-02 04:46:33 UTC


README

GitHub Tests Action Status

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.