keenops/laravel-sms

This package makes easy user of beem.africa API to send sms from laravel applications.

v2.0.0 2022-08-30 15:09 UTC

This package is auto-updated.

Last update: 2024-10-29 06:19:00 UTC


README

Latest Version on Packagist Total Downloads

This package makes it easy to send messages using Beem.africa with Laravel.It is basicly a wrapper around their API.

Installation

You can install the package via composer:

composer require keenops/laravel-sms

After installation, publish the configuration files by running the command:

php artisan vendor:publish --tag=laravel-beem-sms

Usage

Add beem.africa API credentials. Can be obtained here

    BEEM_API_KEY=
    BEEM_API_SECRET=
    BEEM_SENDER_NAME=

Sending SMS

In your controller use like this

namespace App\Http\Controllers;

use Keenops\Sms\Facades\Sms;

class SMSController extends Controller
{
    public function index()
    {
        $message = "Hello Word"; //String
        
        $recipients = ['255701000001', '255701000002', '25570100003']; //array
 
        return Sms::send($message, $recipients);
        //returns a json value with sent status

    }
}

Checking SMS Balance

In your controller use like this

namespace App\Http\Controllers;

use Keenops\Sms\Facades\Sms;

class SMSController extends Controller
{
    public function index()
    {
 
        return Sms::viewBalance();
        //returns Integer value of the remaining balance E.g 210
    }
}

List sender names

In your controller use like this

namespace App\Http\Controllers;

use Keenops\Sms\Facades\Sms;

class SMSController extends Controller
{
    public function index()
    {
 
        return Sms::senderNames();
        //returns json list of registered sender name E.g 210
    }
}

Request a new sender name

In your controller use like this

namespace App\Http\Controllers;

use Keenops\Sms\Facades\Sms;

class SMSController extends Controller
{
    public function index()
    {
 
        return Sms::requestNewSenderName('API TEST','This is test api for new sender name using laravel beem package');
        //return json value of the new requested sender name

    }
}

Errors

Specific error codes may be displayed within parenthesis when send or receive operations fail. The most common of these error codes are specified on beem.africa API Documetation

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email git@kimwalu.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.