syndrom7/ooredoo-sms

Laravel package for Ooredoo SMS Caster API integration

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/syndrom7/ooredoo-sms

dev-master 2025-11-14 20:59 UTC

This package is auto-updated.

Last update: 2025-11-14 21:01:57 UTC


README

A Laravel package for integrating with the Ooredoo SMS Caster API (Maldives).

Requirements

  • PHP 8.1 or higher
  • Laravel 10.x or 11.x

Installation

Install via Composer:

composer require syndrom7/ooredoo-sms

Publish the configuration file:

php artisan vendor:publish --tag=ooredoo-sms-config

Configuration

Add the following to your .env file:

OOREDOO_SMS_BEARER_TOKEN=your-bearer-token
OOREDOO_SMS_USERNAME=your-username
OOREDOO_SMS_ACCESS_KEY=your-access-key

The default endpoint is https://o-papi1-lb01.ooredoo.mv/bulk_sms/v2. You can override this in the published config file or via the OOREDOO_SMS_ENDPOINT environment variable.

Usage

Basic Usage

use Syndrom\OoredooSms\Facades\OoredooSms;

// Send to single recipient
OoredooSms::send('9609166818', 'Your message here');

// Send to multiple recipients
OoredooSms::send(['9609166818', '9609166819'], 'Bulk message');

Fluent API

OoredooSms::to('9609166818')
    ->message('Your message here')
    ->send();

// Multiple recipients
OoredooSms::to(['9609166818', '9609166819'])
    ->message('Bulk message')
    ->send();

Response Handling

The send() method returns the API response as an array:

$response = OoredooSms::send('9609166818', 'Test message');

Successful Response:

[
    'response_code' => 0,
    'response_message' => 'Message sent successfully',
    'delivery_numbers' => '9609166818'
]

Response Fields:

  • response_code: Status code (0 = success)
  • response_message: Human-readable status message
  • delivery_numbers: Comma-separated list of recipient numbers

Usage Example:

$response = OoredooSms::send('9609166818', 'Your message');

if ($response['response_code'] === 0) {
    // SMS sent successfully
    $delivered = $response['delivery_numbers'];
} else {
    // Handle error
    $error = $response['response_message'];
}

Error Handling

The package throws OoredooSmsException for validation errors and API failures:

use Syndrom\OoredooSms\Exceptions\OoredooSmsException;

try {
    OoredooSms::send('9609166818', 'Your message');
} catch (OoredooSmsException $e) {
    // Handle error
    Log::error('SMS failed: ' . $e->getMessage());
}

Testing

composer test

Configuration Options

The following options are available in config/ooredoo-sms.php:

Option Description Default
endpoint API endpoint URL https://o-papi1-lb01.ooredoo.mv/bulk_sms/v2
bearer_token Bearer token for authentication From .env
username Ooredoo account username From .env
access_key API access key From .env
timeout HTTP request timeout (seconds) 30

License

MIT License. See LICENSE for details.