bluesea-cms/semaphore

Laravel Plugin for SMS notification using Semaphore

dev-master 2022-10-14 19:17 UTC

This package is auto-updated.

Last update: 2024-05-14 22:26:10 UTC


README

See Official Semaphore SMS Documentation here

Installation

Usage

Installation

Composer

Run

composer require bluesea-cms/semaphore

or insert in require

"bluesea-cms/semaphore": "dev-master"

Configuration

Run to publish the Configuration

php artisan semaphore:publish

If you want to keep the data on every execution of the method, you might need to publish all the migrations.

To publish all migrations available

php artisan semaphore:publish --migration

Usage

Use the Semaphore Facade

use BlueSea\Semaphore\Facades\Semaphore;

Sending Message

To send a message to a single phone number

$messages = Semaphore::send($number, $message);

To send a message to a multiple phone number

$messages = Semaphore::send([
  $number1, 
  $number2, 
  $number3,
  ...
], $message);

Sending a message, returns an collection of Message model.

You can access the the returned message model by:

$message = $messages->first();

$message->message_id;
$message->account;
$message->recipient;
$message->message;
$message->code;
$message->sender_name;

Sending Priority Message

Normally messages are processed in the order they are received and during periods of heavy traffic messaging, messages can be delayed. With the Semaphore::priority() method, it will bypass the default message queue and sends the message immediately.

*This service is 2 credits per 160 character SMS.

This method takes the same parameters as the send method, and returns the same collection of Message model.

Semaphore::priority($number, $message);

Sending OTP

You can make a custom message included in the OTP sent to the recipient by using the {otp} placeholder

For instance using the message: Your One Time Password is: {otp}. Please use it within 5 minutes.

will return the message Your One Time Password is: XXXXXX. Please use it within 5 minutes.

*This service is 2 credits per 160 character SMS.

This method will return a Message model instance, and you can then get the code by accessing the code object from the model

$otp = Semaphore::otp($number, $message);

$otp->code;

Get Message

To get the Message instance with a specific message_id

$message = Semaphore::find($messageId);

Get All Messages

To get all Messages

 $messages = Semaphore::messages();

By default, this will only return a maximum of 100 messages per page. Add a parameter to access the messages on certain pages

 $messages = Semaphore::messages([
	 'page' => 10,
	 'limit' => 500,		// Default is 100, Maximum of 1000 per page
	 'network' => 'globe', 		// Ex. globe, smart
	 'startDate' => '2020-02-20',	// Format is "YYYY-MM-DD"
	 'endDate', => '2020-12-31',	// Format is "YYYY-MM-DD"
 ]);

Get Account Information

Access your account's information

$account= Semaphore::account();

$account->account_id;

$account->account_name;

$account->status;

$account->credit_balance;

Get All Transactions

Returns a collection of transactions

$transactions = Semaphore::transactions();

$params = [
	 'page' => 10,
	 'limit' => 500, 				// Default is 100, Maximum of 1000 per page
];
$transactions = Semaphore::transactions($params);
 

Get Sender Names

Returns a collection of Sender Names associated with your account

$senderNames = Semaphore::senderNames();

$params = [
	 'page' => 10,
	 'limit' => 500, 				// Default is 100, Maximum of 1000 per page
];

$senderNames = Semaphore::senderNames($params);

Get All users

Returns users associated with your account

$users = Semaphore::users();

$params = [
	 'page' => 10,
	 'limit' => 500, 				// Default is 100, Maximum of 1000 per page
];
$users = Semaphore::users($params);